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