diff options
author | Valerio Virgillito | 2012-06-29 16:03:28 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-06-29 16:03:28 -0700 |
commit | ccd9dd85d39b338c19d51e34b446b126061b07fb (patch) | |
tree | 88f0f3c8db9f49cfb0c88db4c82a6493133d825c /js/controllers | |
parent | ec69c8761f798eaf39c4a154997f8bc54b7e47f4 (diff) | |
parent | 25890906f10e4530f0245632d028a646ece563c1 (diff) | |
download | ninja-ccd9dd85d39b338c19d51e34b446b126061b07fb.tar.gz |
Merge pull request #363 from ericguzman/stylesControllerPatch_6_29
Styles Controller Patch to ignore unfound rules from getMatchedCSSRules
Diffstat (limited to 'js/controllers')
-rwxr-xr-x | js/controllers/styles-controller.js | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 478fc1db..6e363798 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js | |||
@@ -632,7 +632,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
632 | if(!rule) { | 632 | if(!rule) { |
633 | ///// This should never be hit if providing cssText from existing rule (like those | 633 | ///// This should never be hit if providing cssText from existing rule (like those |
634 | ///// returned from getMatchedCSSRules() | 634 | ///// returned from getMatchedCSSRules() |
635 | console.warn('StylesController::_getRuleWithCSSText - No rule found with given cssText.'); | 635 | //console.warn('StylesController::_getRuleWithCSSText - No rule found with given cssText.'); |
636 | } | 636 | } |
637 | 637 | ||
638 | return rule; | 638 | return rule; |
@@ -646,16 +646,31 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
646 | getMatchingRules : { //TODO: Remove omitPseudos from here and usages | 646 | getMatchingRules : { //TODO: Remove omitPseudos from here and usages |
647 | value: function(element, omitPseudos, useStageStyleSheet) { | 647 | value: function(element, omitPseudos, useStageStyleSheet) { |
648 | var rules, | 648 | var rules, |
649 | matchedRules, | ||
649 | mappedRules, | 650 | mappedRules, |
650 | doc = element.ownerDocument, | 651 | doc = element.ownerDocument, |
651 | win = doc.defaultView; | 652 | win = doc.defaultView; |
652 | 653 | ||
654 | if(!element.parentNode) { | ||
655 | //console.warn('StylesController::getMatchingRules - Un-attached element queried'); | ||
656 | return []; | ||
657 | } | ||
658 | |||
653 | try { | 659 | try { |
654 | mappedRules = nj.toArray(win.getMatchedCSSRules(element)).map(function(rule) { | 660 | matchedRules = win.getMatchedCSSRules(element); |
661 | |||
662 | if(!matchedRules) { | ||
663 | //console.warn('StylesController::getMatchingRules - matched rules are null'); | ||
664 | return []; | ||
665 | } | ||
666 | |||
667 | mappedRules = nj.toArray(matchedRules).map(function(rule) { | ||
655 | return this._getRuleWithCSSText(rule.cssText, doc); | 668 | return this._getRuleWithCSSText(rule.cssText, doc); |
656 | }, this); | 669 | }, this); |
657 | 670 | ||
658 | rules = mappedRules.filter(function(rule) { | 671 | rules = mappedRules.filter(function(rule) { |
672 | if(!rule) { return false; } | ||
673 | |||
659 | //// useStageStyleSheet flag indicates whether to only return rules from the stylesheet, | 674 | //// useStageStyleSheet flag indicates whether to only return rules from the stylesheet, |
660 | //// or only use rules for other stylesheets | 675 | //// or only use rules for other stylesheets |
661 | 676 | ||
@@ -676,7 +691,8 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
676 | }, this); | 691 | }, this); |
677 | 692 | ||
678 | } catch(ERROR) { | 693 | } catch(ERROR) { |
679 | console.warn('StylesController::getMatchingRules - Un-attached element queried.'); | 694 | //console.warn('StylesController::getMatchingRules - getMatchedCSSRules Exception.'); |
695 | return []; | ||
680 | } | 696 | } |
681 | ///// Function for sorting by specificity values | 697 | ///// Function for sorting by specificity values |
682 | function sorter(ruleA, ruleB) { | 698 | function sorter(ruleA, ruleB) { |