Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
simplify application of polyfill rules.
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Sep 30, 2013
1 parent 0892107 commit 7255f8c
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions src/ShadowCSS.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ var ShadowCSS = {
}
this.shimPolyfillDirectives(def.rootStyles, name);
this.applyShimming(def.scopeStyles, name);
this.applyPolyfillRules(def.rootStyles, name);
}
},
// Shim styles to be placed inside a shadowRoot.
Expand All @@ -163,7 +162,6 @@ var ShadowCSS = {
shimShadowDOMStyling: function(styles, name) {
this.shimPolyfillDirectives(styles, name);
this.applyShimming(styles, name);
this.applyPolyfillRules(styles, name);
},
registerDefinition: function(root, name, extendsName) {
var def = this.registry[name] = {
Expand Down Expand Up @@ -213,7 +211,8 @@ var ShadowCSS = {
shimPolyfillDirectives: function(styles, name) {
if (styles) {
Array.prototype.forEach.call(styles, function(s) {
s.textContent = this.convertPolyfillDirectives(s.textContent, name);
s.textContent = this.convertPolyfillDirectives(s.textContent, name) +
this.extractPolyfillRules(s.textContent, name) + '\n\n';
}, this);
}
},
Expand All @@ -229,6 +228,14 @@ var ShadowCSS = {
r += cssText.substring(l, cssText.length);
return r;
},
extractPolyfillRules: function(cssText, name) {
var r = '', l = 0, matches, selector;
while (matches = cssPolyfillRuleCommentRe.exec(cssText)) {
rule = matches[1].slice(0, -1).replace(hostRe, name);
r += rule + '\n\n';
}
return r;
},
// apply @host and scope shimming
applyShimming: function(styles, name) {
var cssText = this.shimAtHost(styles, name);
Expand Down Expand Up @@ -385,23 +392,6 @@ var ShadowCSS = {
rule.style.cssText.replace(/content:[^;]*;/g, '');
}
return properties;
},
applyPolyfillRules: function(styles, name) {
if (styles) {
var cssText = '';
Array.prototype.forEach.call(styles, function(s) {
cssText += this.extractPolyfillRules(s.textContent, name) + '\n\n';
}, this);
}
addCssToDocument(cssText);
},
extractPolyfillRules: function(cssText, name) {
var r = '', l = 0, matches, selector;
while (matches = cssPolyfillRuleCommentRe.exec(cssText)) {
rule = matches[1].slice(0, -1).replace(hostRe, name);
r += rule + '\n\n';
}
return r;
}
};

Expand Down

0 comments on commit 7255f8c

Please sign in to comment.