diff options
Diffstat (limited to 'js/controllers/styles-controller.js')
-rwxr-xr-x | js/controllers/styles-controller.js | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index e78c1ef1..33084169 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js | |||
@@ -324,7 +324,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
324 | isInlineStyle : true, | 324 | isInlineStyle : true, |
325 | style : element.style | 325 | style : element.style |
326 | }; | 326 | }; |
327 | 327 | ||
328 | ///// Now splice it into the matched rules | 328 | ///// Now splice it into the matched rules |
329 | ///// By inserting the inline style at the beginning, | 329 | ///// By inserting the inline style at the beginning, |
330 | ///// we keep the correct order of specificity | 330 | ///// we keep the correct order of specificity |
@@ -579,37 +579,36 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
579 | win = element.ownerDocument.defaultView, | 579 | win = element.ownerDocument.defaultView, |
580 | self = this; | 580 | self = this; |
581 | 581 | ||
582 | if(!win) { | ||
583 | return null; | ||
584 | } | ||
585 | |||
586 | if(!omitPseudos) { | 582 | if(!omitPseudos) { |
587 | pseudos.concat(['link', 'visited', 'active', 'hover', 'focus', 'first-letter', | 583 | pseudos.concat(['link', 'visited', 'active', 'hover', 'focus', 'first-letter', |
588 | 'first-line', 'first-child', 'before', 'after', 'lang', 'target']); | 584 | 'first-line', 'first-child', 'before', 'after', 'lang', 'target']); |
589 | } | 585 | } |
590 | 586 | ||
591 | pseudos.forEach(function(pseudo) { | 587 | try { |
592 | rules = rules.concat(nj.toArray(win.getMatchedCSSRules(element, pseudo)).filter(function(rule) { | 588 | pseudos.forEach(function(pseudo) { |
593 | //// useStageStyleSheet flag indicates whether to only return rules from the stylesheet, | 589 | rules = rules.concat(nj.toArray(win.getMatchedCSSRules(element, pseudo)).filter(function(rule) { |
594 | //// or only use rules for other stylesheets | 590 | //// useStageStyleSheet flag indicates whether to only return rules from the stylesheet, |
595 | 591 | //// or only use rules for other stylesheets | |
596 | var sheetId = (rule.parentStyleSheet) ? rule.parentStyleSheet.ownerNode.id : null, | ||
597 | isStageStyleSheet = sheetId === this.CONST.STAGE_SHEET_ID; | ||
598 | 592 | ||
599 | ///// filter out (return false) depending on flag | 593 | var sheetId = (rule.parentStyleSheet) ? rule.parentStyleSheet.ownerNode.id : null, |
600 | if(useStageStyleSheet && !isStageStyleSheet) { return false; } | 594 | isStageStyleSheet = sheetId === this.CONST.STAGE_SHEET_ID; |
601 | if(!useStageStyleSheet && isStageStyleSheet) { return false; } | ||
602 | 595 | ||
603 | ///// Non-filter code - just assigning specificity to the rule | 596 | ///// filter out (return false) depending on flag |
604 | if(!rule[this.CONST.SPECIFICITY_KEY]) { | 597 | if(useStageStyleSheet && !isStageStyleSheet) { return false; } |
605 | rule[this.CONST.SPECIFICITY_KEY] = this.getSpecificity(rule.selectorText); | 598 | if(!useStageStyleSheet && isStageStyleSheet) { return false; } |
606 | } | ||
607 | 599 | ||
608 | return true; | 600 | ///// Non-filter code - just assigning specificity to the rule |
601 | if(!rule[this.CONST.SPECIFICITY_KEY]) { | ||
602 | rule[this.CONST.SPECIFICITY_KEY] = this.getSpecificity(rule.selectorText); | ||
603 | } | ||
609 | 604 | ||
610 | }, this)); | 605 | return true; |
611 | }, this); | ||
612 | 606 | ||
607 | }, this)); | ||
608 | }, this); | ||
609 | } catch(ERROR) { | ||
610 | console.warn('StylesController::getMatchingRules - Un-attached element queried.'); | ||
611 | } | ||
613 | ///// Function for sorting by specificity values | 612 | ///// Function for sorting by specificity values |
614 | function sorter(ruleA, ruleB) { | 613 | function sorter(ruleA, ruleB) { |
615 | var a, b, order, sheetAIndex, sheetBIndex, ruleAIndex, ruleBIndex; | 614 | var a, b, order, sheetAIndex, sheetBIndex, ruleAIndex, ruleBIndex; |
@@ -988,6 +987,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
988 | ///// Pass "true" to method to return an override object, which | 987 | ///// Pass "true" to method to return an override object, which |
989 | ///// has the rule to override, and whether the !important flag is needed | 988 | ///// has the rule to override, and whether the !important flag is needed |
990 | dominantRule = this.getDominantRuleForElement(element, property, true, isStageElement); | 989 | dominantRule = this.getDominantRuleForElement(element, property, true, isStageElement); |
990 | |||
991 | } | 991 | } |
992 | 992 | ||
993 | ///// Did we find a dominant rule? | 993 | ///// Did we find a dominant rule? |