Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Unified Diff: third_party/polymer/v0_8/components-chromium/polymer/src/lib/x-style-extracted.js

Issue 1082403004: Import Polymer 0.8 and several key elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also remove polymer/explainer Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/polymer/v0_8/components-chromium/polymer/src/lib/x-style-extracted.js
diff --git a/third_party/polymer/v0_8/components-chromium/polymer/src/lib/x-style-extracted.js b/third_party/polymer/v0_8/components-chromium/polymer/src/lib/x-style-extracted.js
new file mode 100644
index 0000000000000000000000000000000000000000..885e84a81a116bf8d62f0fdb409e7fb7f66d0ae5
--- /dev/null
+++ b/third_party/polymer/v0_8/components-chromium/polymer/src/lib/x-style-extracted.js
@@ -0,0 +1,47 @@
+
+(function() {
+
+ Polymer({
+
+ is: 'x-style',
+ extends: 'style',
+
+ created: function() {
+ var rules = Polymer.StyleUtil.parser.parse(this.textContent);
+ this.applyProperties(rules);
+ // TODO(sorvell): since custom rules must match directly, they tend to be
+ // made with selectors like `*`.
+ // We *remove them here* so they don't apply too widely and nerf recalc.
+ // This means that normal properties mixe in rules with custom
+ // properties will *not* apply.
+ var cssText = Polymer.StyleUtil.parser.stringify(rules);
+ this.textContent = this.scopeCssText(cssText);
+ },
+
+ scopeCssText: function(cssText) {
+ return Polymer.Settings.useNativeShadow ?
+ cssText :
+ Polymer.StyleUtil.toCssText(cssText, function(rule) {
+ Polymer.StyleTransformer.rootRule(rule);
+ });
+ },
+
+ applyProperties: function(rules) {
+ var cssText = '';
+ Polymer.StyleUtil.forEachStyleRule(rules, function(rule) {
+ if (rule.cssText.match(CUSTOM_RULE)) {
+ // TODO(sorvell): use parser.stringify, it needs an option not to
+ // strip custom properties.
+ cssText += rule.selector + ' {\n' + rule.cssText + '\n}\n';
+ }
+ });
+ if (cssText) {
+ Polymer.StyleDefaults.applyCss(cssText);
+ }
+ }
+
+ });
+
+ var CUSTOM_RULE = /--[^;{'"]*\:/;
+
+})();

Powered by Google App Engine
This is Rietveld 408576698