polymer-rails 0.3.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/polymer/polymer-micro.html +528 -21
- data/app/assets/javascripts/polymer/polymer-mini.html +1304 -27
- data/app/assets/javascripts/polymer/polymer.html +3771 -51
- data/app/assets/javascripts/webcomponentsjs/webcomponents-lite.js +44 -14
- data/app/assets/javascripts/webcomponentsjs/webcomponents.js +7106 -0
- data/lib/polymer-rails/version.rb +1 -1
- metadata +4 -64
- data/app/assets/javascripts/polymer/src/lib/annotations/annotations.html +0 -262
- data/app/assets/javascripts/polymer/src/lib/annotations/demo/app-chrome.html +0 -60
- data/app/assets/javascripts/polymer/src/lib/array-observe.html +0 -118
- data/app/assets/javascripts/polymer/src/lib/array-splice.html +0 -262
- data/app/assets/javascripts/polymer/src/lib/async.html +0 -68
- data/app/assets/javascripts/polymer/src/lib/base.html +0 -117
- data/app/assets/javascripts/polymer/src/lib/bind/accessors.html +0 -223
- data/app/assets/javascripts/polymer/src/lib/bind/demo/app-chrome.html +0 -28
- data/app/assets/javascripts/polymer/src/lib/bind/demo/app.html +0 -29
- data/app/assets/javascripts/polymer/src/lib/bind/demo/src/annotations-bind-demo.html +0 -76
- data/app/assets/javascripts/polymer/src/lib/bind/demo/src/bind-demo.html +0 -83
- data/app/assets/javascripts/polymer/src/lib/bind/effects.html +0 -80
- data/app/assets/javascripts/polymer/src/lib/case-map.html +0 -46
- data/app/assets/javascripts/polymer/src/lib/collection.html +0 -179
- data/app/assets/javascripts/polymer/src/lib/css-parse.html +0 -131
- data/app/assets/javascripts/polymer/src/lib/debounce.html +0 -69
- data/app/assets/javascripts/polymer/src/lib/dom-api.html +0 -467
- data/app/assets/javascripts/polymer/src/lib/dom-module.html +0 -68
- data/app/assets/javascripts/polymer/src/lib/event-api.html +0 -92
- data/app/assets/javascripts/polymer/src/lib/expr/focus.html +0 -22
- data/app/assets/javascripts/polymer/src/lib/expr/gestures.html +0 -1
- data/app/assets/javascripts/polymer/src/lib/expr/log.html +0 -21
- data/app/assets/javascripts/polymer/src/lib/expr/sinspect.html +0 -235
- data/app/assets/javascripts/polymer/src/lib/expr/style-auditor.html +0 -123
- data/app/assets/javascripts/polymer/src/lib/expr/style-protector.html +0 -52
- data/app/assets/javascripts/polymer/src/lib/gestures.html +0 -284
- data/app/assets/javascripts/polymer/src/lib/lang.html +0 -21
- data/app/assets/javascripts/polymer/src/lib/module.html +0 -56
- data/app/assets/javascripts/polymer/src/lib/polymer-bootstrap.html +0 -78
- data/app/assets/javascripts/polymer/src/lib/resolve-url.html +0 -82
- data/app/assets/javascripts/polymer/src/lib/settings.html +0 -52
- data/app/assets/javascripts/polymer/src/lib/style-defaults.html +0 -32
- data/app/assets/javascripts/polymer/src/lib/style-transformer.html +0 -185
- data/app/assets/javascripts/polymer/src/lib/style-util.html +0 -77
- data/app/assets/javascripts/polymer/src/lib/template/templatizer.html +0 -132
- data/app/assets/javascripts/polymer/src/lib/template/x-array-selector.html +0 -178
- data/app/assets/javascripts/polymer/src/lib/template/x-autobind.html +0 -80
- data/app/assets/javascripts/polymer/src/lib/template/x-if.html +0 -115
- data/app/assets/javascripts/polymer/src/lib/template/x-repeat.html +0 -510
- data/app/assets/javascripts/polymer/src/lib/template/x-template.html +0 -39
- data/app/assets/javascripts/polymer/src/lib/x-style.html +0 -115
- data/app/assets/javascripts/polymer/src/micro/attributes.html +0 -180
- data/app/assets/javascripts/polymer/src/micro/constructor.html +0 -74
- data/app/assets/javascripts/polymer/src/micro/extends.html +0 -79
- data/app/assets/javascripts/polymer/src/micro/mixins.html +0 -40
- data/app/assets/javascripts/polymer/src/micro/properties.html +0 -96
- data/app/assets/javascripts/polymer/src/micro/tag.html +0 -28
- data/app/assets/javascripts/polymer/src/mini/ready.html +0 -180
- data/app/assets/javascripts/polymer/src/mini/shadow.html +0 -41
- data/app/assets/javascripts/polymer/src/mini/shady.html +0 -365
- data/app/assets/javascripts/polymer/src/mini/template.html +0 -56
- data/app/assets/javascripts/polymer/src/polymer-lib.html +0 -15
- data/app/assets/javascripts/polymer/src/standard/annotations.html +0 -198
- data/app/assets/javascripts/polymer/src/standard/configure.html +0 -160
- data/app/assets/javascripts/polymer/src/standard/effects.html +0 -215
- data/app/assets/javascripts/polymer/src/standard/events.html +0 -127
- data/app/assets/javascripts/polymer/src/standard/notify-path.html +0 -260
- data/app/assets/javascripts/polymer/src/standard/resolveUrl.html +0 -27
- data/app/assets/javascripts/polymer/src/standard/styling.html +0 -157
- data/app/assets/javascripts/polymer/src/standard/utils.html +0 -158
- data/app/assets/javascripts/polymer/src/standard/x-styling.html +0 -300
@@ -1,158 +0,0 @@
|
|
1
|
-
<!--
|
2
|
-
@license
|
3
|
-
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
4
|
-
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
5
|
-
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
6
|
-
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
7
|
-
Code distributed by Google as part of the polymer project is also
|
8
|
-
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
9
|
-
-->
|
10
|
-
|
11
|
-
<link rel="import" href="../lib/async.html">
|
12
|
-
<link rel="import" href="../lib/debounce.html">
|
13
|
-
|
14
|
-
<script>
|
15
|
-
|
16
|
-
Polymer.Base.addFeature({
|
17
|
-
|
18
|
-
$$: function(slctr) {
|
19
|
-
return Polymer.dom(this.root).querySelector(slctr);
|
20
|
-
},
|
21
|
-
|
22
|
-
toggleClass: function(name, bool, node) {
|
23
|
-
node = node || this;
|
24
|
-
if (arguments.length == 1) {
|
25
|
-
bool = !node.classList.contains(name);
|
26
|
-
}
|
27
|
-
if (bool) {
|
28
|
-
node.classList.add(name);
|
29
|
-
} else {
|
30
|
-
node.classList.remove(name);
|
31
|
-
}
|
32
|
-
},
|
33
|
-
|
34
|
-
toggleAttribute: function(name, bool, node) {
|
35
|
-
(node || this)[bool ? 'setAttribute' : 'removeAttribute'](name, '');
|
36
|
-
},
|
37
|
-
|
38
|
-
classFollows: function(className, neo, old) {
|
39
|
-
if (old) {
|
40
|
-
old.classList.remove(className);
|
41
|
-
}
|
42
|
-
if (neo) {
|
43
|
-
neo.classList.add(className);
|
44
|
-
}
|
45
|
-
},
|
46
|
-
|
47
|
-
attributeFollows: function(name, neo, old) {
|
48
|
-
if (old) {
|
49
|
-
old.removeAttribute(name);
|
50
|
-
}
|
51
|
-
if (neo) {
|
52
|
-
neo.setAttribute(name, '');
|
53
|
-
}
|
54
|
-
},
|
55
|
-
|
56
|
-
getContentChildNodes: function(slctr) {
|
57
|
-
return Polymer.dom(Polymer.dom(this.root).querySelector(
|
58
|
-
slctr || 'content')).getDistributedNodes();
|
59
|
-
},
|
60
|
-
|
61
|
-
getContentChildren: function(slctr) {
|
62
|
-
return this.getContentChildNodes(slctr).filter(function(n) {
|
63
|
-
return (n.nodeType === Node.ELEMENT_NODE);
|
64
|
-
});
|
65
|
-
},
|
66
|
-
|
67
|
-
// TODO(sjmiles): use a dictionary for options after `detail`
|
68
|
-
fire: function(type, detail, onNode, bubbles, cancelable) {
|
69
|
-
var node = onNode || this;
|
70
|
-
var detail = (detail === null || detail === undefined) ? {} : detail;
|
71
|
-
var event = new CustomEvent(type, {
|
72
|
-
bubbles: bubbles !== undefined ? bubbles : true,
|
73
|
-
cancelable: cancelable !== undefined ? cancelable : true,
|
74
|
-
detail: detail
|
75
|
-
});
|
76
|
-
node.dispatchEvent(event);
|
77
|
-
return event;
|
78
|
-
},
|
79
|
-
|
80
|
-
async: function(method, waitTime) {
|
81
|
-
return Polymer.Async.run(method.bind(this), waitTime);
|
82
|
-
},
|
83
|
-
|
84
|
-
cancelAsync: function(handle) {
|
85
|
-
Polymer.Async.cancel(handle);
|
86
|
-
},
|
87
|
-
|
88
|
-
arrayDelete: function(array, item) {
|
89
|
-
var index = array.indexOf(item);
|
90
|
-
if (index >= 0) {
|
91
|
-
return array.splice(index, 1);
|
92
|
-
}
|
93
|
-
},
|
94
|
-
|
95
|
-
transform: function(node, transform) {
|
96
|
-
node.style.webkitTransform = transform;
|
97
|
-
node.style.transform = transform;
|
98
|
-
},
|
99
|
-
|
100
|
-
translate3d: function(node, x, y, z) {
|
101
|
-
this.transform(node, 'translate3d(' + x + ',' + y + ',' + z + ')');
|
102
|
-
},
|
103
|
-
|
104
|
-
importHref: function(href, onload, onerror) {
|
105
|
-
var l = document.createElement('link');
|
106
|
-
l.rel = 'import';
|
107
|
-
l.href = href;
|
108
|
-
if (onload) {
|
109
|
-
l.onload = onload.bind(this);
|
110
|
-
}
|
111
|
-
if (onerror) {
|
112
|
-
l.onerror = onerror.bind(this);
|
113
|
-
}
|
114
|
-
document.head.appendChild(l);
|
115
|
-
return l;
|
116
|
-
},
|
117
|
-
|
118
|
-
/**
|
119
|
-
* Debounce signals.
|
120
|
-
*
|
121
|
-
* Call `debounce` to collapse multiple requests for a named task into
|
122
|
-
* one invocation which is made after the wait time has elapsed with
|
123
|
-
* no new request.
|
124
|
-
*
|
125
|
-
* debouncedClickAction: function(e) {
|
126
|
-
* // will not call `processClick` more than once per 100ms
|
127
|
-
* this.debounce('click', function() {
|
128
|
-
* this.processClick;
|
129
|
-
* }, 100);
|
130
|
-
* }
|
131
|
-
*
|
132
|
-
* @method debounce
|
133
|
-
* @param String {String} jobName A string to indentify the debounce job.
|
134
|
-
* @param Function {Function} callback A function that is called (with `this` context) when the wait time elapses.
|
135
|
-
* @param Number {Number} wait Time in milliseconds (ms) after the last signal that must elapse before invoking `callback`
|
136
|
-
* @type Handle
|
137
|
-
*/
|
138
|
-
debounce: function(jobName, callback, wait) {
|
139
|
-
this._debounce('_job_' + jobName, callback, wait);
|
140
|
-
},
|
141
|
-
|
142
|
-
_debounce: function(job, callback, wait) {
|
143
|
-
this[job] = Polymer.Debounce.call(this, this[job], callback, wait);
|
144
|
-
},
|
145
|
-
|
146
|
-
create: function(tag, props) {
|
147
|
-
var elt = document.createElement(tag);
|
148
|
-
if (props) {
|
149
|
-
for (var n in props) {
|
150
|
-
elt[n] = props[n];
|
151
|
-
}
|
152
|
-
}
|
153
|
-
return elt;
|
154
|
-
}
|
155
|
-
|
156
|
-
});
|
157
|
-
|
158
|
-
</script>
|
@@ -1,300 +0,0 @@
|
|
1
|
-
<!--
|
2
|
-
@license
|
3
|
-
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
4
|
-
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
5
|
-
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
6
|
-
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
7
|
-
Code distributed by Google as part of the polymer project is also
|
8
|
-
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
9
|
-
-->
|
10
|
-
<link rel="import" href="../lib/style-util.html">
|
11
|
-
<link rel="import" href="../lib/style-transformer.html">
|
12
|
-
<link rel="import" href="../lib/settings.html">
|
13
|
-
<link rel="import" href="../lib/style-defaults.html">
|
14
|
-
<script>
|
15
|
-
(function() {
|
16
|
-
|
17
|
-
var baseAttachedCallback = Polymer.Base.attachedCallback;
|
18
|
-
|
19
|
-
// TODO(sorvell): consider if calculating properties and applying
|
20
|
-
// styles with properties should be separate modules.
|
21
|
-
Polymer.Base.addFeature({
|
22
|
-
|
23
|
-
attachedCallback: function() {
|
24
|
-
baseAttachedCallback.call(this);
|
25
|
-
if (this.enableCustomStyleProperties && !this._scopeSelector) {
|
26
|
-
this._updateOwnStyles();
|
27
|
-
}
|
28
|
-
},
|
29
|
-
|
30
|
-
_updateOwnStyles: function() {
|
31
|
-
if (this.enableCustomStyleProperties) {
|
32
|
-
this._styleProperties = this._computeStyleProperties();
|
33
|
-
this.applyStyleProperties(this._styleProperties);
|
34
|
-
}
|
35
|
-
},
|
36
|
-
|
37
|
-
_computeStyleProperties: function() {
|
38
|
-
var props = {};
|
39
|
-
this.simpleMixin(props, this._computeStylePropertiesFromHost());
|
40
|
-
this.simpleMixin(props, this._computeOwnStyleProperties());
|
41
|
-
this._reifyCustomProperties(props);
|
42
|
-
return props;
|
43
|
-
},
|
44
|
-
|
45
|
-
_computeStylePropertiesFromHost: function() {
|
46
|
-
// TODO(sorvell): experimental feature, global defaults!
|
47
|
-
var props = {}, styles = [Polymer.StyleDefaults.defaultSheet];
|
48
|
-
if (this.host) {
|
49
|
-
// enable finding styles in hosts without `enableStyleCustomProperties`
|
50
|
-
if (!this.host._styleProperties) {
|
51
|
-
this.host._styleProperties = this.host._computeStyleProperties();
|
52
|
-
}
|
53
|
-
props = Object.create(this.host._styleProperties);
|
54
|
-
styles = this.host._styles;
|
55
|
-
}
|
56
|
-
this.simpleMixin(props,
|
57
|
-
this._customPropertiesFromStyles(styles, this.host));
|
58
|
-
return props;
|
59
|
-
|
60
|
-
},
|
61
|
-
|
62
|
-
_computeOwnStyleProperties: function() {
|
63
|
-
var props = {};
|
64
|
-
this.simpleMixin(props, this._customPropertiesFromStyles(this._styles));
|
65
|
-
if (this.styleProperties) {
|
66
|
-
for (var i in this.styleProperties) {
|
67
|
-
props[i] = this.styleProperties[i];
|
68
|
-
}
|
69
|
-
}
|
70
|
-
return props;
|
71
|
-
},
|
72
|
-
|
73
|
-
_customPropertiesFromStyles: function(styles, hostNode) {
|
74
|
-
var props = {};
|
75
|
-
var p = this._customPropertiesFromRule.bind(this, props, hostNode);
|
76
|
-
if (styles) {
|
77
|
-
for (var i=0, l=styles.length, s; (i<l) && (s=styles[i]); i++) {
|
78
|
-
Polymer.StyleUtil.forEachStyleRule(this._rulesForStyle(s), p);
|
79
|
-
}
|
80
|
-
}
|
81
|
-
return props;
|
82
|
-
},
|
83
|
-
|
84
|
-
// test if a rule matches the given node and if so,
|
85
|
-
// collect any custom properties
|
86
|
-
// TODO(sorvell): support custom variable assignment within mixins
|
87
|
-
_customPropertiesFromRule: function(props, hostNode, rule) {
|
88
|
-
hostNode = hostNode || this;
|
89
|
-
// TODO(sorvell): file crbug, ':host' does not match element.
|
90
|
-
if (this.elementMatches(rule.selector) ||
|
91
|
-
((hostNode === this) && (rule.selector === ':host'))) {
|
92
|
-
// --g: var(--b); or --g: 5;
|
93
|
-
this._collectPropertiesFromRule(rule, CUSTOM_VAR_ASSIGN, props);
|
94
|
-
// --g: { ... }
|
95
|
-
this._collectPropertiesFromRule(rule, CUSTOM_MIXIN_ASSIGN, props);
|
96
|
-
}
|
97
|
-
},
|
98
|
-
|
99
|
-
// given a rule and rx that matches key and value, set key in properties
|
100
|
-
// to value
|
101
|
-
_collectPropertiesFromRule: function(rule, rx, properties) {
|
102
|
-
var m;
|
103
|
-
while (m = rx.exec(rule.cssText)) {
|
104
|
-
properties[m[1]] = m[2].trim();
|
105
|
-
}
|
106
|
-
},
|
107
|
-
|
108
|
-
_reifyCustomProperties: function(props) {
|
109
|
-
for (var i in props) {
|
110
|
-
props[i] = this._valueForCustomProperty(props[i], props);
|
111
|
-
}
|
112
|
-
},
|
113
|
-
|
114
|
-
_valueForCustomProperty: function(property, props) {
|
115
|
-
var cv;
|
116
|
-
while ((typeof property === 'string') &&
|
117
|
-
(cv = property.match(CUSTOM_VAR_VALUE))) {
|
118
|
-
property = props[cv[1]];
|
119
|
-
}
|
120
|
-
return property;
|
121
|
-
},
|
122
|
-
|
123
|
-
// apply styles
|
124
|
-
applyStyleProperties: function(bag) {
|
125
|
-
var s$ = this._styles;
|
126
|
-
if (s$) {
|
127
|
-
var style = styleFromCache(this.is, bag, s$);
|
128
|
-
this._ensureScopeSelector(style ? style._scope : null);
|
129
|
-
if (!style) {
|
130
|
-
var cssText = this._generateCustomStyleCss(bag, s$);
|
131
|
-
style = cssText ? this._applyCustomCss(cssText) : {};
|
132
|
-
cacheStyle(this.is, style, this._scopeSelector,
|
133
|
-
this._styleProperties, s$);
|
134
|
-
} else if (Polymer.Settings.useNativeShadow) {
|
135
|
-
this._applyCustomCss(style.textContent);
|
136
|
-
}
|
137
|
-
if (style.textContent /*&& !Polymer.Settings.useNativeShadow*/) {
|
138
|
-
this.setAttribute(XSCOPE_ATTR, this._scopeSelector);
|
139
|
-
}
|
140
|
-
}
|
141
|
-
},
|
142
|
-
|
143
|
-
_generateCustomStyleCss: function(properties, styles) {
|
144
|
-
var b = this._applyPropertiesToRule.bind(this, properties);
|
145
|
-
var cssText = '';
|
146
|
-
// TODO(sorvell): don't redo parsing work each time as below;
|
147
|
-
// instead create a sheet with just custom properties
|
148
|
-
for (var i=0, l=styles.length, s; (i<l) && (s=styles[i]); i++) {
|
149
|
-
cssText += this._transformCss(s.textContent, b) + '\n\n';
|
150
|
-
}
|
151
|
-
return cssText.trim();
|
152
|
-
},
|
153
|
-
|
154
|
-
_transformCss: function(cssText, callback) {
|
155
|
-
return Polymer.Settings.useNativeShadow ?
|
156
|
-
Polymer.StyleUtil.toCssText(cssText, callback) :
|
157
|
-
Polymer.StyleTransformer.css(cssText, this.is, this.extends, callback);
|
158
|
-
},
|
159
|
-
|
160
|
-
_xScopeCount: 0,
|
161
|
-
|
162
|
-
_ensureScopeSelector: function(selector) {
|
163
|
-
if (!this._scopeSelector) {
|
164
|
-
var c = Object.getPrototypeOf(this)._xScopeCount++;
|
165
|
-
this._scopeSelector = selector || (this.is + '-' + c);
|
166
|
-
}
|
167
|
-
},
|
168
|
-
|
169
|
-
_applyCustomCss: function(cssText) {
|
170
|
-
if (this._customStyle) {
|
171
|
-
this._customStyle.textContent = cssText;
|
172
|
-
} else if (cssText) {
|
173
|
-
this._customStyle = Polymer.StyleUtil.applyCss(cssText,
|
174
|
-
this._scopeSelector,
|
175
|
-
Polymer.Settings.useNativeShadow ? this.root : null);
|
176
|
-
}
|
177
|
-
return this._customStyle;
|
178
|
-
},
|
179
|
-
|
180
|
-
_applyPropertiesToRule: function(properties, rule) {
|
181
|
-
if (!Polymer.Settings.useNativeShadow) {
|
182
|
-
this._scopifyRule(rule);
|
183
|
-
}
|
184
|
-
if (rule.cssText.match(CUSTOM_RULE_RX)) {
|
185
|
-
rule.cssText = this._applyPropertiesToText(rule.cssText, properties);
|
186
|
-
} else {
|
187
|
-
rule.cssText = '';
|
188
|
-
}
|
189
|
-
//console.log(rule.cssText);
|
190
|
-
},
|
191
|
-
|
192
|
-
_applyPropertiesToText: function(cssText, props) {
|
193
|
-
var output = '';
|
194
|
-
var m, v;
|
195
|
-
// e.g. color: var(--color);
|
196
|
-
while (m = CUSTOM_VAR_USE.exec(cssText)) {
|
197
|
-
v = props[m[2]];
|
198
|
-
if (v) {
|
199
|
-
output += '\t' + m[1].trim() + ': ' + this._propertyToCss(v);
|
200
|
-
}
|
201
|
-
}
|
202
|
-
// e.g. @mixin(--stuff);
|
203
|
-
while (m = CUSTOM_MIXIN_USE.exec(cssText)) {
|
204
|
-
v = m[1];
|
205
|
-
if (v) {
|
206
|
-
var parts = v.split(' ');
|
207
|
-
for (var i=0, p; i < parts.length; i++) {
|
208
|
-
p = props[parts[i].trim()];
|
209
|
-
if (p) {
|
210
|
-
output += '\t' + this._propertyToCss(p);
|
211
|
-
}
|
212
|
-
}
|
213
|
-
}
|
214
|
-
}
|
215
|
-
return output;
|
216
|
-
},
|
217
|
-
|
218
|
-
_propertyToCss: function(property) {
|
219
|
-
var p = property.trim();
|
220
|
-
p = p[p.length-1] === ';' ? p : p + ';';
|
221
|
-
return p + '\n';
|
222
|
-
},
|
223
|
-
|
224
|
-
_scopifyRule: function(rule) {
|
225
|
-
var selector = rule.selector;
|
226
|
-
var host = this.is;
|
227
|
-
var rx = new RegExp(host + HOST_SELECTOR_SEP);
|
228
|
-
var parts = selector.split(',');
|
229
|
-
var scope = SCOPE_PREFIX + this._scopeSelector + SCOPE_SUFFIX;
|
230
|
-
for (var i=0, l=parts.length, p; (i<l) && (p=parts[i]); i++) {
|
231
|
-
parts[i] = p.match(rx) ?
|
232
|
-
p.replace(host, host + scope) :
|
233
|
-
scope + ' ' + p;
|
234
|
-
}
|
235
|
-
rule.selector = parts.join(',');
|
236
|
-
},
|
237
|
-
|
238
|
-
updateStyles: function() {
|
239
|
-
this._updateOwnStyles();
|
240
|
-
// TODO(sorvell): temporary way to find local dom that needs
|
241
|
-
// x-scope styling.
|
242
|
-
var c$ = Polymer.dom(this.root).querySelectorAll('[x-style-scope]');
|
243
|
-
for (var i=0, l= c$.length, c; (i<l) && (c=c$[i]); i++) {
|
244
|
-
if (c.updateStyles) {
|
245
|
-
c.updateStyles();
|
246
|
-
}
|
247
|
-
}
|
248
|
-
}
|
249
|
-
|
250
|
-
});
|
251
|
-
|
252
|
-
var styleCache = {};
|
253
|
-
function cacheStyle(is, style, scope, bag, styles) {
|
254
|
-
style._scope = scope;
|
255
|
-
style._properties = bag;
|
256
|
-
style._styles = styles;
|
257
|
-
var s$ = styleCache[is] = styleCache[is] || [];
|
258
|
-
s$.push(style);
|
259
|
-
}
|
260
|
-
|
261
|
-
function styleFromCache(is, bag, checkStyles) {
|
262
|
-
var styles = styleCache[is];
|
263
|
-
if (styles) {
|
264
|
-
for (var i=0, s; i < styles.length; i++) {
|
265
|
-
s = styles[i];
|
266
|
-
if (objectsEqual(bag, s._properties) &&
|
267
|
-
objectsEqual(checkStyles, s._styles)) {
|
268
|
-
return s;
|
269
|
-
}
|
270
|
-
}
|
271
|
-
}
|
272
|
-
}
|
273
|
-
|
274
|
-
function objectsEqual(a, b) {
|
275
|
-
for (var i in a) {
|
276
|
-
if (a[i] !== b[i]) {
|
277
|
-
return false;
|
278
|
-
}
|
279
|
-
}
|
280
|
-
for (var i in b) {
|
281
|
-
if (a[i] !== b[i]) {
|
282
|
-
return false;
|
283
|
-
}
|
284
|
-
}
|
285
|
-
return true;
|
286
|
-
}
|
287
|
-
|
288
|
-
var XSCOPE_ATTR = 'x-style-scope';
|
289
|
-
var SCOPE_PREFIX = '[' + XSCOPE_ATTR + '=';
|
290
|
-
var SCOPE_SUFFIX = ']';
|
291
|
-
var HOST_SELECTOR_SEP = '($|[\\.\\:\\[\\s>\\+~])';
|
292
|
-
var CUSTOM_RULE_RX = /mixin|var/;
|
293
|
-
var CUSTOM_VAR_ASSIGN = /(--[^\:;]*?):\s*?([^;{]*?);/g;
|
294
|
-
var CUSTOM_MIXIN_ASSIGN = /(--[^\:;]*?):[^{;]*?{([^}]*?)}/g;
|
295
|
-
var CUSTOM_VAR_VALUE = /^var\(([^)]*?)\)/;
|
296
|
-
var CUSTOM_VAR_USE = /(?:^|[;}\s])([^;{}]*?):[\s]*?var\(([^)]*)?\)/gim;
|
297
|
-
var CUSTOM_MIXIN_USE = /mixin\(([^)]*)\)/gim;
|
298
|
-
|
299
|
-
})();
|
300
|
-
</script>
|