Skip to content

Commit

Permalink
Fix :nth-child, :not and similar selector modifiers in panel. Fixes #249
Browse files Browse the repository at this point in the history
  • Loading branch information
ankit committed Jul 11, 2013
1 parent 0a00aaf commit bbab063
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 7 additions & 3 deletions stylebot/editor/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,21 +175,25 @@ stylebot.style = {
*/
applyPageCSS: function(css, shouldSave, data) {
if (shouldSave === undefined) { shouldSave = true; }

var parsedRules = {};

if (css != '') {
if (!this.parser)
if (!this.parser) {
this.parser = new CSSParser();
}

try {
var sheet = this.parser.parse(css, false, true);
parsedRules = CSSUtils.getRulesFromParserObject(sheet);
} catch (e) {
console.log(e);
return false;
}
}

if (parsedRules['error']) { return parsedRules['error']; }
if (parsedRules['error']) {
return parsedRules['error'];
}

this.clearInlineCSS(this.cache.elements);
this.updateStyleElement(parsedRules);
Expand Down
6 changes: 6 additions & 0 deletions stylebot/libs/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3994,6 +3994,9 @@ CSSParser.prototype = {
if (!canNegate)
return null;
token = this.getToken(true, true);
if (!token.isNotNull()) {
return null;
}
var simpleSelector = this.parseSimpleSelector(token, isFirstInChain, false);
if (!simpleSelector)
return null;
Expand All @@ -4010,6 +4013,9 @@ CSSParser.prototype = {
else {
while (true) {
token = this.getToken(false, true);
if (!token.isNotNull()) {
break;
}
if (token.isSymbol(")")) {
s += ")";
break;
Expand Down

1 comment on commit bbab063

@LiamKarlMitchell
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ankit Could you please increase version and re-deploy to chrome webstore?

Please sign in to comment.