OLD | NEW |
1 <!-- | 1 <!-- |
2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | 2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | 3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | 4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | 5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
6 Code distributed by Google as part of the polymer project is also | 6 Code distributed by Google as part of the polymer project is also |
7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | 7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
8 --> | 8 --> |
9 <!-- | 9 <!-- |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 :host { | 39 :host { |
40 backgound-color: steelblue; | 40 backgound-color: steelblue; |
41 } | 41 } |
42 </core-style> | 42 </core-style> |
43 | 43 |
44 The content of the `x-test` `core-style` producer gets included inside the | 44 The content of the `x-test` `core-style` producer gets included inside the |
45 shadowRoot of the `x-test` element. If the content of the `x-test` producer | 45 shadowRoot of the `x-test` element. If the content of the `x-test` producer |
46 `core-style` changes, all consumers of it are automatically kept in sync. This | 46 `core-style` changes, all consumers of it are automatically kept in sync. This |
47 allows updating styling on the fly. | 47 allows updating styling on the fly. |
48 | 48 |
49 The `core-style` element also supports bindings and it is the producer | 49 The `core-style` element also supports bindings, in which case the producer |
50 `core-style` element is the model for its content. Here's an example: | 50 `core-style` element is the model. Here's an example: |
51 | 51 |
52 <core-style id="x-test"> | 52 <core-style id="x-test"> |
53 :host { | 53 :host { |
54 background-color: {{myColor}}; | 54 background-color: {{myColor}}; |
55 } | 55 } |
56 </core-style> | 56 </core-style> |
57 <script> | 57 <script> |
58 document._currentScript.ownerDocument.getElementById('x-test').myColor = '
orange'; | 58 document._currentScript.ownerDocument.getElementById('x-test').myColor = '
orange'; |
59 </script> | 59 </script> |
60 | 60 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 //console.log('require', this.ref, cssText); | 258 //console.log('require', this.ref, cssText); |
259 if (cssText) { | 259 if (cssText) { |
260 this.ensureStyleElement(); | 260 this.ensureStyleElement(); |
261 // do nothing if cssText has not changed | 261 // do nothing if cssText has not changed |
262 if (this.styleElement._cssText === cssText) { | 262 if (this.styleElement._cssText === cssText) { |
263 return; | 263 return; |
264 } | 264 } |
265 this.styleElement._cssText = cssText; | 265 this.styleElement._cssText = cssText; |
266 if (window.ShadowDOMPolyfill) { | 266 if (window.ShadowDOMPolyfill) { |
267 this.styleElement.textContent = cssText; | 267 this.styleElement.textContent = cssText; |
268 cssText = Platform.ShadowCSS.shimStyle(this.styleElement, | 268 cssText = WebComponents.ShadowCSS.shimStyle(this.styleElement, |
269 this.getScopeSelector()); | 269 this.getScopeSelector()); |
270 } | 270 } |
271 this.styleElement.textContent = cssText; | 271 this.styleElement.textContent = cssText; |
272 } | 272 } |
273 }, | 273 }, |
274 | 274 |
275 cssTextForRef: function(ref) { | 275 cssTextForRef: function(ref) { |
276 var s$ = this.byId(ref); | 276 var s$ = this.byId(ref); |
277 var cssText = ''; | 277 var cssText = ''; |
278 if (s$) { | 278 if (s$) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 return style; | 326 return style; |
327 } | 327 } |
328 }, | 328 }, |
329 | 329 |
330 getScopeSelector: function() { | 330 getScopeSelector: function() { |
331 if (!this._scopeSelector) { | 331 if (!this._scopeSelector) { |
332 var selector = '', host = this.findHost(this); | 332 var selector = '', host = this.findHost(this); |
333 if (host) { | 333 if (host) { |
334 var typeExtension = host.hasAttribute('is'); | 334 var typeExtension = host.hasAttribute('is'); |
335 var name = typeExtension ? host.getAttribute('is') : host.localName; | 335 var name = typeExtension ? host.getAttribute('is') : host.localName; |
336 selector = Platform.ShadowCSS.makeScopeSelector(name, | 336 selector = WebComponents.ShadowCSS.makeScopeSelector(name, |
337 typeExtension); | 337 typeExtension); |
338 } | 338 } |
339 this._scopeSelector = selector; | 339 this._scopeSelector = selector; |
340 } | 340 } |
341 return this._scopeSelector; | 341 return this._scopeSelector; |
342 }, | 342 }, |
343 | 343 |
344 findHost: function(node) { | 344 findHost: function(node) { |
345 while (node.parentNode) { | 345 while (node.parentNode) { |
346 node = node.parentNode; | 346 node = node.parentNode; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 b: parseInt(result[3], 16) | 378 b: parseInt(result[3], 16) |
379 } : null; | 379 } : null; |
380 } | 380 } |
381 | 381 |
382 }); | 382 }); |
383 | 383 |
384 | 384 |
385 })(); | 385 })(); |
386 </script> | 386 </script> |
387 </polymer-element> | 387 </polymer-element> |
OLD | NEW |