Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // Teaches dart2js about the wrapping that is done by the Shadow DOM polyfill. | 5 // Teaches dart2js about the wrapping that is done by the Shadow DOM polyfill. |
| 6 (function() { | 6 (function() { |
| 7 var ShadowDOMPolyfill = window.ShadowDOMPolyfill; | 7 var ShadowDOMPolyfill = window.ShadowDOMPolyfill; |
| 8 if (!ShadowDOMPolyfill) return; | 8 if (!ShadowDOMPolyfill) return; |
| 9 | 9 |
| 10 if (navigator.userAgent.indexOf('(Dart)') !== -1) { | 10 if (navigator.userAgent.indexOf('(Dart)') !== -1) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 if (!upgrader) return; | 109 if (!upgrader) return; |
| 110 name = name.toLowerCase(); | 110 name = name.toLowerCase(); |
| 111 var existing = upgraders[name]; | 111 var existing = upgraders[name]; |
| 112 if (existing) { | 112 if (existing) { |
| 113 console.error('Already have a Dart type associated with ' + name); | 113 console.error('Already have a Dart type associated with ' + name); |
| 114 return; | 114 return; |
| 115 } | 115 } |
| 116 upgraders[name] = upgrader; | 116 upgraders[name] = upgrader; |
| 117 } | 117 } |
| 118 | 118 |
| 119 | |
| 120 // Native custom elements outside the app in Chrome have constructor | |
| 121 // names like "x-tag", which need to be translated to the DOM | |
| 122 // element they extend. When using the shadow dom polyfill this is | |
| 123 // take care of above. | |
|
Siggi Cherem (dart-lang)
2014/06/11 19:56:03
nit: take => taken
| |
| 124 var ShadowDOMPolyfill = window.ShadowDOMPolyfill; | |
| 125 if (!ShadowDOMPolyfill) { | |
| 126 // dartNativeDispatchHooksTransformer is described on initHooks() in | |
| 127 // sdk/lib/_internal/lib/native_helper.dart. | |
| 128 if (typeof window.dartNativeDispatchHooksTransformer == 'undefined') | |
| 129 window.dartNativeDispatchHooksTransformer = []; | |
| 130 | |
| 131 window.dartNativeDispatchHooksTransformer.push(function(hooks) { | |
| 132 var originalGetUnknownTag = hooks.getUnknownTag; | |
| 133 hooks.getUnknownTag = function(o, tag) { | |
| 134 if (/-/.test(tag)) { // "x-tag" | |
| 135 var s = Object.prototype.toString.call(o); | |
| 136 var match = s.match(/^\[object ([A-Za-z]*Element)\]$/); | |
| 137 if (match) { | |
| 138 return match[1]; | |
| 139 } | |
| 140 return originalGetUnknownTag(o, tag); | |
| 141 } | |
| 142 }; | |
| 143 }); | |
| 144 } | |
| 145 | |
| 119 doc._registerDartTypeUpgrader = registerDartTypeUpgrader; | 146 doc._registerDartTypeUpgrader = registerDartTypeUpgrader; |
| 120 doc.registerElement = registerElement; | 147 doc.registerElement = registerElement; |
| 121 })(document); | 148 })(document); |
| OLD | NEW |