Skip to content

Commit

Permalink
Define checkRoot only once
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Sep 23, 2016
1 parent c2278a0 commit a49b366
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/lib/style-properties.html
Original file line number Diff line number Diff line change
Expand Up @@ -285,21 +285,23 @@
return {properties: props, key: o};
},

_checkRoot: function(hostScope, selector) {
return selector.indexOf(':root') === 0 ||
(hostScope === 'html' && selector.indexOf('html') === 0);
},

whenHostOrRootRule: function(scope, rule, style, callback) {
if (!rule.propertyInfo) {
self.decorateRule(rule);
}
if (!rule.propertyInfo.properties) {
return;
}
var checkRoot = function(hostScope, selector) {
return selector.indexOf(':root') === 0 || (hostScope === 'html' && selector.indexOf('html') === 0);
};
var hostScope = scope.is ?
styleTransformer._calcHostScope(scope.is, scope.extends) :
'html';
var parsedSelector = rule.parsedSelector;
var isRoot = checkRoot(hostScope, parsedSelector);
var isRoot = this._checkRoot(hostScope, parsedSelector);
var isHost = parsedSelector.indexOf(':host') === 0;
// build info is either in scope (when scope is an element) or in the style
// when scope is the default scope; note: this allows default scope to have
Expand All @@ -312,7 +314,7 @@
isHost = !isRoot && parsedSelector.indexOf(hostScope) === 0;
}
if (cssBuild === 'shadow') {
isRoot = parsedSelector === ':host > *' || checkRoot(hostScope, parsedSelector);
isRoot = parsedSelector === ':host > *' || this._checkRoot(hostScope, parsedSelector);
isHost = isHost && !isRoot;
}
if (!isRoot && !isHost) {
Expand Down

0 comments on commit a49b366

Please sign in to comment.