Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /** | |
| 2 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | |
|
Siggi Cherem (dart-lang)
2014/09/10 22:13:52
seems odd that this part is removed?
jakemac
2014/09/10 22:37:43
fixed
| |
| 3 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.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/CON TRIBUTORS.txt | |
| 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/PA TENTS.txt | |
| 8 */ | |
| 9 | |
| 10 window.Platform = window.Platform || {}; | |
| 11 // prepopulate window.logFlags if necessary | |
| 12 window.logFlags = window.logFlags || {}; | |
| 13 // process flags | |
| 14 (function(scope){ | |
| 15 // import | |
| 16 var flags = scope.flags || {}; | |
| 17 // populate flags from location | |
| 18 location.search.slice(1).split('&').forEach(function(o) { | |
| 19 o = o.split('='); | |
| 20 o[0] && (flags[o[0]] = o[1] || true); | |
| 21 }); | |
| 22 var entryPoint = document.currentScript || | |
| 23 document.querySelector('script[src*="platform.js"]'); | |
| 24 if (entryPoint) { | |
| 25 var a = entryPoint.attributes; | |
| 26 for (var i = 0, n; i < a.length; i++) { | |
| 27 n = a[i]; | |
| 28 if (n.name !== 'src') { | |
| 29 flags[n.name] = n.value || true; | |
| 30 } | |
| 31 } | |
| 32 } | |
| 33 if (flags.log) { | |
| 34 flags.log.split(',').forEach(function(f) { | |
| 35 window.logFlags[f] = true; | |
| 36 }); | |
| 37 } | |
| 38 // If any of these flags match 'native', then force native ShadowDOM; any | |
| 39 // other truthy value, or failure to detect native | |
| 40 // ShadowDOM, results in polyfill | |
| 41 flags.shadow = flags.shadow || flags.shadowdom || flags.polyfill; | |
| 42 if (flags.shadow === 'native') { | |
| 43 flags.shadow = false; | |
| 44 } else { | |
| 45 flags.shadow = flags.shadow || !HTMLElement.prototype.createShadowRoot; | |
| 46 } | |
| 47 | |
| 48 if (flags.shadow && document.querySelectorAll('script').length > 1) { | |
| 49 console.warn('platform.js is not the first script on the page. ' + | |
| 50 'See http://www.polymer-project.org/docs/start/platform.html#setup ' + | |
| 51 'for details.'); | |
| 52 } | |
| 53 | |
| 54 // CustomElements polyfill flag | |
| 55 if (flags.register) { | |
| 56 window.CustomElements = window.CustomElements || {flags: {}}; | |
| 57 window.CustomElements.flags.register = flags.register; | |
| 58 } | |
| 59 | |
| 60 if (flags.imports) { | |
| 61 window.HTMLImports = window.HTMLImports || {flags: {}}; | |
| 62 window.HTMLImports.flags.imports = flags.imports; | |
| 63 } | |
| 64 | |
| 65 // export | |
| 66 scope.flags = flags; | |
| 67 })(Platform); | |
| 68 | |
| 69 /* | 1 /* |
| 70 * Copyright 2012 The Polymer Authors. All rights reserved. | 2 * Copyright 2012 The Polymer Authors. All rights reserved. |
| 71 * Use of this source code is governed by a BSD-style | 3 * Use of this source code is governed by a BSD-style |
| 72 * license that can be found in the LICENSE file. | 4 * license that can be found in the LICENSE file. |
| 73 */ | 5 */ |
| 74 | 6 |
| 75 if (typeof WeakMap === 'undefined') { | 7 if (typeof WeakMap === 'undefined') { |
| 76 (function() { | 8 (function() { |
| 77 var defineProperty = Object.defineProperty; | 9 var defineProperty = Object.defineProperty; |
| 78 var counter = Date.now() % 1e9; | 10 var counter = Date.now() % 1e9; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 105 var entry = key[this.name]; | 37 var entry = key[this.name]; |
| 106 if (!entry) return false; | 38 if (!entry) return false; |
| 107 return entry[0] === key; | 39 return entry[0] === key; |
| 108 } | 40 } |
| 109 }; | 41 }; |
| 110 | 42 |
| 111 window.WeakMap = WeakMap; | 43 window.WeakMap = WeakMap; |
| 112 })(); | 44 })(); |
| 113 } | 45 } |
| 114 | 46 |
| 115 // select ShadowDOM impl | |
| 116 if (Platform.flags.shadow) { | |
| 117 | |
| 118 // Copyright 2012 Google Inc. | 47 // Copyright 2012 Google Inc. |
| 119 // | 48 // |
| 120 // Licensed under the Apache License, Version 2.0 (the "License"); | 49 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 121 // you may not use this file except in compliance with the License. | 50 // you may not use this file except in compliance with the License. |
| 122 // You may obtain a copy of the License at | 51 // You may obtain a copy of the License at |
| 123 // | 52 // |
| 124 // http://www.apache.org/licenses/LICENSE-2.0 | 53 // http://www.apache.org/licenses/LICENSE-2.0 |
| 125 // | 54 // |
| 126 // Unless required by applicable law or agreed to in writing, software | 55 // Unless required by applicable law or agreed to in writing, software |
| 127 // distributed under the License is distributed on an "AS IS" BASIS, | 56 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 2192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2320 'use strict'; | 2249 'use strict'; |
| 2321 | 2250 |
| 2322 var setEndOfMicrotask = scope.setEndOfMicrotask | 2251 var setEndOfMicrotask = scope.setEndOfMicrotask |
| 2323 var wrapIfNeeded = scope.wrapIfNeeded | 2252 var wrapIfNeeded = scope.wrapIfNeeded |
| 2324 var wrappers = scope.wrappers; | 2253 var wrappers = scope.wrappers; |
| 2325 | 2254 |
| 2326 var registrationsTable = new WeakMap(); | 2255 var registrationsTable = new WeakMap(); |
| 2327 var globalMutationObservers = []; | 2256 var globalMutationObservers = []; |
| 2328 var isScheduled = false; | 2257 var isScheduled = false; |
| 2329 | 2258 |
| 2330 function scheduleCallback(observer) { | 2259 function scheduleCallback() { |
| 2331 if (isScheduled) | 2260 if (isScheduled) |
| 2332 return; | 2261 return; |
| 2333 setEndOfMicrotask(notifyObservers); | 2262 setEndOfMicrotask(notifyObservers); |
| 2334 isScheduled = true; | 2263 isScheduled = true; |
| 2335 } | 2264 } |
| 2336 | 2265 |
| 2337 // http://dom.spec.whatwg.org/#mutation-observers | 2266 // http://dom.spec.whatwg.org/#mutation-observers |
| 2338 function notifyObservers() { | 2267 function notifyObservers() { |
| 2339 isScheduled = false; | 2268 isScheduled = false; |
| 2340 | 2269 |
| 2341 do { | 2270 while (globalMutationObservers.length) { |
| 2342 var notifyList = globalMutationObservers.slice(); | 2271 var notifyList = globalMutationObservers; |
| 2343 var anyNonEmpty = false; | 2272 globalMutationObservers = []; |
| 2273 | |
| 2274 // Deliver changes in birth order of the MutationObservers. | |
| 2275 notifyList.sort(function(x, y) { return x.uid_ - y.uid_; }); | |
| 2276 | |
| 2344 for (var i = 0; i < notifyList.length; i++) { | 2277 for (var i = 0; i < notifyList.length; i++) { |
| 2345 var mo = notifyList[i]; | 2278 var mo = notifyList[i]; |
| 2346 var queue = mo.takeRecords(); | 2279 var queue = mo.takeRecords(); |
| 2347 removeTransientObserversFor(mo); | 2280 removeTransientObserversFor(mo); |
| 2348 if (queue.length) { | 2281 if (queue.length) { |
| 2349 mo.callback_(queue, mo); | 2282 mo.callback_(queue, mo); |
| 2350 anyNonEmpty = true; | |
| 2351 } | 2283 } |
| 2352 } | 2284 } |
| 2353 } while (anyNonEmpty); | 2285 } |
| 2354 } | 2286 } |
| 2355 | 2287 |
| 2288 | |
| 2356 /** | 2289 /** |
| 2357 * @param {string} type | 2290 * @param {string} type |
| 2358 * @param {Node} target | 2291 * @param {Node} target |
| 2359 * @constructor | 2292 * @constructor |
| 2360 */ | 2293 */ |
| 2361 function MutationRecord(type, target) { | 2294 function MutationRecord(type, target) { |
| 2362 this.type = type; | 2295 this.type = type; |
| 2363 this.target = target; | 2296 this.target = target; |
| 2364 this.addedNodes = new wrappers.NodeList(); | 2297 this.addedNodes = new wrappers.NodeList(); |
| 2365 this.removedNodes = new wrappers.NodeList(); | 2298 this.removedNodes = new wrappers.NodeList(); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2451 // true, or type is "characterData" and options's characterDataOldValue | 2384 // true, or type is "characterData" and options's characterDataOldValue |
| 2452 // is true, set the paired string of registered observer's observer in | 2385 // is true, set the paired string of registered observer's observer in |
| 2453 // interested observers to oldValue. | 2386 // interested observers to oldValue. |
| 2454 if (type === 'attributes' && options.attributeOldValue || | 2387 if (type === 'attributes' && options.attributeOldValue || |
| 2455 type === 'characterData' && options.characterDataOldValue) { | 2388 type === 'characterData' && options.characterDataOldValue) { |
| 2456 associatedStrings[observer.uid_] = data.oldValue; | 2389 associatedStrings[observer.uid_] = data.oldValue; |
| 2457 } | 2390 } |
| 2458 } | 2391 } |
| 2459 } | 2392 } |
| 2460 | 2393 |
| 2461 var anyRecordsEnqueued = false; | 2394 var anyObserversEnqueued = false; |
| 2462 | 2395 |
| 2463 // 4. | 2396 // 4. |
| 2464 for (var uid in interestedObservers) { | 2397 for (var uid in interestedObservers) { |
| 2465 var observer = interestedObservers[uid]; | 2398 var observer = interestedObservers[uid]; |
| 2466 var record = new MutationRecord(type, target); | 2399 var record = new MutationRecord(type, target); |
| 2467 | 2400 |
| 2468 // 2. | 2401 // 2. |
| 2469 if ('name' in data && 'namespace' in data) { | 2402 if ('name' in data && 'namespace' in data) { |
| 2470 record.attributeName = data.name; | 2403 record.attributeName = data.name; |
| 2471 record.attributeNamespace = data.namespace; | 2404 record.attributeNamespace = data.namespace; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 2485 | 2418 |
| 2486 // 6. | 2419 // 6. |
| 2487 if (data.nextSibling) | 2420 if (data.nextSibling) |
| 2488 record.nextSibling = data.nextSibling; | 2421 record.nextSibling = data.nextSibling; |
| 2489 | 2422 |
| 2490 // 7. | 2423 // 7. |
| 2491 if (associatedStrings[uid] !== undefined) | 2424 if (associatedStrings[uid] !== undefined) |
| 2492 record.oldValue = associatedStrings[uid]; | 2425 record.oldValue = associatedStrings[uid]; |
| 2493 | 2426 |
| 2494 // 8. | 2427 // 8. |
| 2428 if (!observer.records_.length) { | |
| 2429 globalMutationObservers.push(observer); | |
| 2430 anyObserversEnqueued = true; | |
| 2431 } | |
| 2495 observer.records_.push(record); | 2432 observer.records_.push(record); |
| 2496 | |
| 2497 anyRecordsEnqueued = true; | |
| 2498 } | 2433 } |
| 2499 | 2434 |
| 2500 if (anyRecordsEnqueued) | 2435 if (anyObserversEnqueued) |
| 2501 scheduleCallback(); | 2436 scheduleCallback(); |
| 2502 } | 2437 } |
| 2503 | 2438 |
| 2504 var slice = Array.prototype.slice; | 2439 var slice = Array.prototype.slice; |
| 2505 | 2440 |
| 2506 /** | 2441 /** |
| 2507 * @param {!Object} options | 2442 * @param {!Object} options |
| 2508 * @constructor | 2443 * @constructor |
| 2509 */ | 2444 */ |
| 2510 function MutationObserverOptions(options) { | 2445 function MutationObserverOptions(options) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2554 /** | 2489 /** |
| 2555 * The class that maps to the DOM MutationObserver interface. | 2490 * The class that maps to the DOM MutationObserver interface. |
| 2556 * @param {Function} callback. | 2491 * @param {Function} callback. |
| 2557 * @constructor | 2492 * @constructor |
| 2558 */ | 2493 */ |
| 2559 function MutationObserver(callback) { | 2494 function MutationObserver(callback) { |
| 2560 this.callback_ = callback; | 2495 this.callback_ = callback; |
| 2561 this.nodes_ = []; | 2496 this.nodes_ = []; |
| 2562 this.records_ = []; | 2497 this.records_ = []; |
| 2563 this.uid_ = ++uidCounter; | 2498 this.uid_ = ++uidCounter; |
| 2564 | |
| 2565 // This will leak. There is no way to implement this without WeakRefs :'( | |
| 2566 globalMutationObservers.push(this); | |
| 2567 } | 2499 } |
| 2568 | 2500 |
| 2569 MutationObserver.prototype = { | 2501 MutationObserver.prototype = { |
| 2570 constructor: MutationObserver, | 2502 constructor: MutationObserver, |
| 2571 | 2503 |
| 2572 // http://dom.spec.whatwg.org/#dom-mutationobserver-observe | 2504 // http://dom.spec.whatwg.org/#dom-mutationobserver-observe |
| 2573 observe: function(target, options) { | 2505 observe: function(target, options) { |
| 2574 target = wrapIfNeeded(target); | 2506 target = wrapIfNeeded(target); |
| 2575 | 2507 |
| 2576 var newOptions = new MutationObserverOptions(options); | 2508 var newOptions = new MutationObserverOptions(options); |
| (...skipping 6299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8876 | 8808 |
| 8877 } | 8809 } |
| 8878 }); | 8810 }); |
| 8879 } | 8811 } |
| 8880 | 8812 |
| 8881 // exports | 8813 // exports |
| 8882 scope.ShadowCSS = ShadowCSS; | 8814 scope.ShadowCSS = ShadowCSS; |
| 8883 | 8815 |
| 8884 })(window.Platform); | 8816 })(window.Platform); |
| 8885 | 8817 |
| 8886 } else { | |
| 8887 /* | 8818 /* |
| 8888 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | 8819 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 8889 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt | 8820 * This code may only be used under the BSD style license found at http://polyme r.github.io/LICENSE.txt |
| 8890 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt | 8821 * The complete set of authors may be found at http://polymer.github.io/AUTHORS. txt |
| 8891 * The complete set of contributors may be found at http://polymer.github.io/CON TRIBUTORS.txt | 8822 * The complete set of contributors may be found at http://polymer.github.io/CON TRIBUTORS.txt |
| 8892 * Code distributed by Google as part of the polymer project is also | 8823 * Code distributed by Google as part of the polymer project is also |
| 8893 * subject to an additional IP rights grant found at http://polymer.github.io/PA TENTS.txt | 8824 * subject to an additional IP rights grant found at http://polymer.github.io/PA TENTS.txt |
| 8894 */ | 8825 */ |
| 8895 | 8826 |
| 8896 (function(scope) { | 8827 (function(scope) { |
| 8897 | 8828 |
| 8898 // so we can call wrap/unwrap without testing for ShadowDOMPolyfill | 8829 // so we can call wrap/unwrap without testing for ShadowDOMPolyfill |
| 8899 window.wrap = window.unwrap = function(n){ | 8830 window.wrap = window.unwrap = function(n){ |
| 8900 return n; | 8831 return n; |
| 8901 } | 8832 } |
| 8902 | 8833 |
| 8903 addEventListener('DOMContentLoaded', function() { | 8834 addEventListener('DOMContentLoaded', function() { |
| 8904 if (CustomElements.useNative === false) { | 8835 if (CustomElements.useNative === false) { |
| 8905 var originalCreateShadowRoot = Element.prototype.createShadowRoot; | 8836 var originalCreateShadowRoot = Element.prototype.createShadowRoot; |
| 8906 Element.prototype.createShadowRoot = function() { | 8837 Element.prototype.createShadowRoot = function() { |
| 8907 var root = originalCreateShadowRoot.call(this); | 8838 var root = originalCreateShadowRoot.call(this); |
| 8908 CustomElements.watchShadow(this); | 8839 CustomElements.watchShadow(this); |
| 8909 return root; | 8840 return root; |
| 8910 }; | 8841 }; |
| 8911 } | 8842 } |
| 8912 }); | 8843 }); |
| 8913 | 8844 |
| 8914 })(window.Platform); | 8845 })(window.Platform); |
| 8915 | 8846 |
| 8916 } | |
| 8917 /* Any copyright is dedicated to the Public Domain. | 8847 /* Any copyright is dedicated to the Public Domain. |
| 8918 * http://creativecommons.org/publicdomain/zero/1.0/ */ | 8848 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
| 8919 | 8849 |
| 8920 (function(scope) { | 8850 (function(scope) { |
| 8921 'use strict'; | 8851 'use strict'; |
| 8922 | 8852 |
| 8923 // feature detect for URL constructor | 8853 // feature detect for URL constructor |
| 8924 var hasWorkingUrl = false; | 8854 var hasWorkingUrl = false; |
| 8925 if (!scope.forceJURL) { | 8855 if (!scope.forceJURL) { |
| 8926 try { | 8856 try { |
| (...skipping 3327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12254 // exports | 12184 // exports |
| 12255 | 12185 |
| 12256 scope.marshal = marshal; | 12186 scope.marshal = marshal; |
| 12257 // `module` confuses commonjs detectors | 12187 // `module` confuses commonjs detectors |
| 12258 scope.modularize = module; | 12188 scope.modularize = module; |
| 12259 scope.using = using; | 12189 scope.using = using; |
| 12260 | 12190 |
| 12261 })(window); | 12191 })(window); |
| 12262 | 12192 |
| 12263 //# sourceMappingURL=platform.concat.js.map | 12193 //# sourceMappingURL=platform.concat.js.map |
| OLD | NEW |