diff --git a/jQuery.cssParentSelector.js b/jQuery.cssParentSelector.js index 91834cb..dd1d3f0 100644 --- a/jQuery.cssParentSelector.js +++ b/jQuery.cssParentSelector.js @@ -73,9 +73,9 @@ declarations = declarations.replace(/;/g, ' !important;'); - for (j = -1; selectors[++j], selector = $.trim(selectors[j]);) { + var hasChild = false; - j && (parsed += ','); + for (j = -1; selectors[++j], selector = $.trim(selectors[j]);) { if (/!/.test(selector) ) { @@ -97,6 +97,9 @@ // E! P > F:state => state state = (selector.split('>')[1].split(/:+/)[1] || '').split(' ')[0] || []._; + if(child.length){ + hasChild = true; + } child.each(function(i) { @@ -124,7 +127,7 @@ $(subject).toggleClass(id) }; - i && (parsed += ','); + (j || i) && (parsed += ','); parsed += '.' + id; var $this = $(this); @@ -139,7 +142,12 @@ } } - parsed += declarations; + if(hasChild){ + + parsed += declarations; + + } + };