| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Final phase of the polymer transformation: includes any additional polyfills | 6 * Final phase of the polymer transformation: includes any additional polyfills |
| 7 * that may needed by the deployed app. | 7 * that may needed by the deployed app. |
| 8 */ | 8 */ |
| 9 library polymer.src.build.polyfill_injector; | 9 library polymer.src.build.polyfill_injector; |
| 10 | 10 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // Replace all other Dart script tags with JavaScript versions. | 79 // Replace all other Dart script tags with JavaScript versions. |
| 80 for (var script in dartScripts) { | 80 for (var script in dartScripts) { |
| 81 final src = script.attributes['src']; | 81 final src = script.attributes['src']; |
| 82 if (src.endsWith('.dart')) { | 82 if (src.endsWith('.dart')) { |
| 83 script.attributes.remove('type'); | 83 script.attributes.remove('type'); |
| 84 script.attributes['src'] = '$src$csp.js'; | 84 script.attributes['src'] = '$src$csp.js'; |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 // Remove "packages/browser/dart.js" | 87 // Remove "packages/browser/dart.js" |
| 88 if (dartJs != null) dartJs.remove(); | 88 if (dartJs != null) dartJs.remove(); |
| 89 } else if (dartJs == null) { |
| 90 document.body.nodes.add(parseFragment( |
| 91 '<script src="packages/browser/dart.js"></script>')); |
| 89 } | 92 } |
| 90 | 93 |
| 91 _addScript(urlSegment) { | 94 _addScript(urlSegment) { |
| 92 document.body.nodes.insert(0, parseFragment( | 95 document.head.nodes.insert(0, parseFragment( |
| 93 '<script src="packages/$urlSegment"></script>\n')); | 96 '<script src="packages/$urlSegment"></script>\n')); |
| 94 } | 97 } |
| 95 | 98 |
| 96 // JS interop code is required for Polymer CSS shimming. | 99 // JS interop code is required for Polymer CSS shimming. |
| 97 if (!jsInteropFound) _addScript('browser/interop.js'); | 100 if (!jsInteropFound) _addScript('browser/interop.js'); |
| 98 if (!customElementFound) { | 101 if (!customElementFound) { |
| 99 _addScript('custom_element/custom-elements.debug.js'); | 102 _addScript('custom_element/custom-elements.debug.js'); |
| 100 } | 103 } |
| 101 | 104 |
| 102 // This polyfill needs to be the first one on the body | 105 // This polyfill needs to be the first one on the head |
| 103 // TODO(jmesserly): this is .debug to workaround issue 13046. | 106 // TODO(jmesserly): this is .debug to workaround issue 13046. |
| 104 if (!shadowDomFound) _addScript('shadow_dom/shadow_dom.debug.js'); | 107 if (!shadowDomFound) _addScript('shadow_dom/shadow_dom.debug.js'); |
| 105 | 108 |
| 106 transform.addOutput( | 109 transform.addOutput( |
| 107 new Asset.fromString(transform.primaryInput.id, document.outerHtml)); | 110 new Asset.fromString(transform.primaryInput.id, document.outerHtml)); |
| 108 }); | 111 }); |
| 109 } | 112 } |
| 110 } | 113 } |
| 111 | 114 |
| 112 final _shadowDomJS = new RegExp(r'shadow_dom\..*\.js', caseSensitive: false); | 115 final _shadowDomJS = new RegExp(r'shadow_dom\..*\.js', caseSensitive: false); |
| 113 final _customElementJS = new RegExp(r'custom-elements\..*\.js', | 116 final _customElementJS = new RegExp(r'custom-elements\..*\.js', |
| 114 caseSensitive: false); | 117 caseSensitive: false); |
| OLD | NEW |