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 // dartNativeDispatchHooksTransformer is described on initHooks() in | |
120 // sdk/lib/_internal/lib/native_helper.dart. | |
121 if (typeof window.dartNativeDispatchHooksTransformer == 'undefined') | |
122 window.dartNativeDispatchHooksTransformer = []; | |
123 | |
124 window.dartNativeDispatchHooksTransformer.push(function(hooks) { | |
Siggi Cherem (dart-lang)
2014/06/11 19:34:57
should we also check for !!ShadowDOMPOlyfill?
See
sra1
2014/06/11 19:43:24
Done.
| |
125 var originalGetUnknownTag = hooks.getUnknownTag; | |
126 hooks.getUnknownTag = function(o, tag) { | |
127 // Custom elements outside the app in chrome have a constructor | |
128 // names like "x-b". | |
Siggi Cherem (dart-lang)
2014/06/11 19:34:57
nit: say x-tag instead of x-b (more commonly used
sra1
2014/06/11 19:43:24
Done.
| |
129 if (/-/.test(tag)) { | |
130 var s = Object.prototype.toString.call(o); | |
131 var match = s.match(/^\[object ([A-Za-z]*)\]$/); | |
Siggi Cherem (dart-lang)
2014/06/11 19:34:57
let's add Element in the regex
sra1
2014/06/11 19:43:24
Done.
| |
132 if (match) { | |
133 var name = match[1]; | |
134 if (name != "Object") return name; | |
135 } | |
136 return originalGetUnknownTag(o, tag); | |
137 } | |
138 }; | |
139 }); | |
140 | |
119 doc._registerDartTypeUpgrader = registerDartTypeUpgrader; | 141 doc._registerDartTypeUpgrader = registerDartTypeUpgrader; |
120 doc.registerElement = registerElement; | 142 doc.registerElement = registerElement; |
121 })(document); | 143 })(document); |
OLD | NEW |