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 <link href="core-transition-pages.html" rel="import"> | 10 <link href="core-transition-pages.html" rel="import"> |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 | 211 |
212 scope._heroes.push(h); | 212 scope._heroes.push(h); |
213 } | 213 } |
214 } | 214 } |
215 | 215 |
216 }, | 216 }, |
217 | 217 |
218 // carefully look into ::shadow with polyfill specific hack | 218 // carefully look into ::shadow with polyfill specific hack |
219 findInShadows: function(node, selector) { | 219 findInShadows: function(node, selector) { |
220 return node.querySelector(selector) || (hasShadowDOMPolyfill ? | 220 return node.querySelector(selector) || (hasShadowDOMPolyfill ? |
221 Platform.queryAllShadows(node, selector) : | 221 queryAllShadows(node, selector) : |
222 node.querySelector('::shadow ' + selector)); | 222 node.querySelector('::shadow ' + selector)); |
223 }, | 223 }, |
224 | 224 |
225 findAllInShadows: function(node, selector) { | 225 findAllInShadows: function(node, selector) { |
226 if (hasShadowDOMPolyfill) { | 226 if (hasShadowDOMPolyfill) { |
227 var nodes = node.querySelectorAll(selector).array(); | 227 var nodes = node.querySelectorAll(selector).array(); |
228 var shadowNodes = Platform.queryAllShadows(node, selector, true); | 228 var shadowNodes = queryAllShadows(node, selector, true); |
229 return nodes.concat(shadowNodes); | 229 return nodes.concat(shadowNodes); |
230 } else { | 230 } else { |
231 return node.querySelectorAll(selector).array().concat(node.shadowRoot ?
node.shadowRoot.querySelectorAll(selector).array() : []); | 231 return node.querySelectorAll(selector).array().concat(node.shadowRoot ?
node.shadowRoot.querySelectorAll(selector).array() : []); |
232 } | 232 } |
233 }, | 233 }, |
234 | 234 |
235 ensureComplete: function(scope) { | 235 ensureComplete: function(scope) { |
236 this.super(arguments); | 236 this.super(arguments); |
237 if (scope._heroes) { | 237 if (scope._heroes) { |
238 scope._heroes.forEach(function(h) { | 238 scope._heroes.forEach(function(h) { |
(...skipping 14 matching lines...) Expand all Loading... |
253 }); | 253 }); |
254 | 254 |
255 if (done) { | 255 if (done) { |
256 this.super(arguments); | 256 this.super(arguments); |
257 } | 257 } |
258 // } | 258 // } |
259 } | 259 } |
260 | 260 |
261 }); | 261 }); |
262 | 262 |
| 263 |
| 264 // utility method for searching through shadowRoots. |
| 265 function queryShadow(node, selector) { |
| 266 var m, el = node.firstElementChild; |
| 267 var shadows, sr, i; |
| 268 shadows = []; |
| 269 sr = node.shadowRoot; |
| 270 while(sr) { |
| 271 shadows.push(sr); |
| 272 sr = sr.olderShadowRoot; |
| 273 } |
| 274 for(i = shadows.length - 1; i >= 0; i--) { |
| 275 m = shadows[i].querySelector(selector); |
| 276 if (m) { |
| 277 return m; |
| 278 } |
| 279 } |
| 280 while(el) { |
| 281 m = queryShadow(el, selector); |
| 282 if (m) { |
| 283 return m; |
| 284 } |
| 285 el = el.nextElementSibling; |
| 286 } |
| 287 return null; |
| 288 } |
| 289 |
| 290 function _queryAllShadows(node, selector, results) { |
| 291 var el = node.firstElementChild; |
| 292 var temp, sr, shadows, i, j; |
| 293 shadows = []; |
| 294 sr = node.shadowRoot; |
| 295 while(sr) { |
| 296 shadows.push(sr); |
| 297 sr = sr.olderShadowRoot; |
| 298 } |
| 299 for (i = shadows.length - 1; i >= 0; i--) { |
| 300 temp = shadows[i].querySelectorAll(selector); |
| 301 for(j = 0; j < temp.length; j++) { |
| 302 results.push(temp[j]); |
| 303 } |
| 304 } |
| 305 while (el) { |
| 306 _queryAllShadows(el, selector, results); |
| 307 el = el.nextElementSibling; |
| 308 } |
| 309 return results; |
| 310 } |
| 311 |
| 312 queryAllShadows = function(node, selector, all) { |
| 313 if (all) { |
| 314 return _queryAllShadows(node, selector, []); |
| 315 } else { |
| 316 return queryShadow(node, selector); |
| 317 } |
| 318 }; |
| 319 |
263 })(); | 320 })(); |
264 </script> | 321 </script> |
265 </polymer-element> | 322 </polymer-element> |
266 | 323 |
267 <hero-transition id="hero-transition"></hero-transition> | 324 <hero-transition id="hero-transition"></hero-transition> |
OLD | NEW |