Skip to content

Commit

Permalink
bug fix: cssDeclaration regex
Browse files Browse the repository at this point in the history
  • Loading branch information
premasagar committed Apr 9, 2010
1 parent e41f6bb commit 1f98c3e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions important.js
Expand Up @@ -36,7 +36,7 @@

// return a regular expression of a declaration, with the backreferences as the CSS property and the value
function regexDeclaration(property){
return new RegExp('[\\^\\s;](' + property + ')\\s*:\\s*([^;]*(?:;|$))', 'i');
return new RegExp('(?:^|\\s|;)(' + property + ')\\s*:\\s*([^;]*(?:;|$))', 'i');
}
function find(property, rules){
return rules.match(regexDeclaration(property));
Expand Down Expand Up @@ -109,9 +109,9 @@
if (!re){
re = htmlStylesToImportant.re =
/(?=<style[^>]*>)([\w\W]*?)(?=<\/style>)/g;
}
return html.replace(re, function($0, rulesets){
return toImportant(rulesets, makeImportant);
}
return html.replace(re, function($0, rulesets){
return toImportant(rulesets, makeImportant);
});
}

Expand Down Expand Up @@ -267,6 +267,7 @@
property = method;
makeImportant = (args[1] !== false);

_([property, makeImportant, cssDeclaration(property, makeImportant, elem.attr('style'))]);
elem.attr('style', cssDeclaration(property, makeImportant, elem.attr('style')));
}
}
Expand Down

0 comments on commit 1f98c3e

Please sign in to comment.