<commit_before>/*
Script: ART.Sheet.js

License:
	MIT-style license.
*/

ART.Sheet = {};

(function(){
	// http://www.w3.org/TR/CSS21/cascade.html#specificity
	var rules = [];

	var parseSelector = function(selector){
		var result = [];
		if (selector.tag && selector.tag != '*'){
			result.push(selector.tag);
		}
		if (selector.pseudos) selector.pseudos.each(function(pseudo){
			result.push(':' + pseudo.name);
		});
		if (selector.classes) selector.classes.each(function(klass){
			result.push('.' + klass);
		});
		return result;
	};

	var getSpecificity = function(selector){
		specificity = 0;
		selector.each(function(chunk){
			if (chunk.tag && chunk.tag != '*') specificity++;
			specificity += (chunk.pseudos || []).length;
			specificity += (chunk.classes || []).length * 100;
		});
		return specificity;
	};

	ART.Sheet.defineStyle = function(selectors, style){
		SubtleSlickParse(selectors).each(function(selector){
			var rule = {
				'specificity': getSpecificity(selector),
				'selector': parseSelector(selector[0]),
				'style': {}
			};
			for (p in style) rule.style[p.camelCase()] = style[p];
			rules.push(rule);
		});
	};

	ART.Sheet.lookupStyle = function(selector){
		var style = {};
		rules.sort(function(a, b){
			return a.specificity - b.specificity;
		});

		selector = parseSelector(SubtleSlickParse(selector)[0][0]);
		rules.each(function(rule){
			if (rule.selector.every(function(chunk){
				return selector.contains(chunk);
			})){
				$mixin(style, rule.style);
			}
		});

		return style;
	};
})();
<commit_msg>passing a full selector to parseSelector<commit_after>/*
Script: ART.Sheet.js

License:
	MIT-style license.
*/

ART.Sheet = {};

(function(){
	// http://www.w3.org/TR/CSS21/cascade.html#specificity
	var rules = [];

	var parseSelector = function(selector){
		var chunk = selector[0];
		var result = [];
		if (chunk.tag && chunk.tag != '*'){
			result.push(chunk.tag);
		}
		if (chunk.pseudos) chunk.pseudos.each(function(pseudo){
			result.push(':' + pseudo.name);
		});
		if (chunk.classes) chunk.classes.each(function(klass){
			result.push('.' + klass);
		});
		return result;
	};

	var getSpecificity = function(selector){
		specificity = 0;
		selector.each(function(chunk){
			if (chunk.tag && chunk.tag != '*') specificity++;
			specificity += (chunk.pseudos || []).length;
			specificity += (chunk.classes || []).length * 100;
		});
		return specificity;
	};

	ART.Sheet.defineStyle = function(selectors, style){
		SubtleSlickParse(selectors).each(function(selector){
			var rule = {
				'specificity': getSpecificity(selector),
				'selector': parseSelector(selector),
				'style': {}
			};
			for (p in style) rule.style[p.camelCase()] = style[p];
			rules.push(rule);
		});
	};

	ART.Sheet.lookupStyle = function(selector){
		var style = {};
		rules.sort(function(a, b){
			return a.specificity - b.specificity;
		});

		selector = parseSelector(SubtleSlickParse(selector)[0]);
		rules.each(function(rule){
			if (rule.selector.every(function(chunk){
				return selector.contains(chunk);
			})){
				$mixin(style, rule.style);
			}
		});

		return style;
	};
})();

{'fraction_non_alphanumeric': 0.18635926993275698, 'fraction_numerical': 0.006083893691962856, 'mean_word_length': 3.8359133126934983, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7287205', 'n_tokens_mistral': 1222, 'n_tokens_neox': 1058, 'n_words': 186}