| 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 library polymer.polymer_element; | 5 library polymer.polymer_element; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'dart:mirrors'; | 9 import 'dart:mirrors'; |
| 10 import 'dart:js' as dartJs; |
| 10 | 11 |
| 11 import 'package:custom_element/custom_element.dart'; | 12 import 'package:custom_element/custom_element.dart'; |
| 12 import 'package:js/js.dart' as js; | 13 import 'package:js/js.dart' as js; |
| 13 import 'package:mdv/mdv.dart' show NodeBinding; | 14 import 'package:mdv/mdv.dart' show NodeBinding; |
| 14 import 'package:observe/observe.dart'; | 15 import 'package:observe/observe.dart'; |
| 15 import 'package:observe/src/microtask.dart'; | 16 import 'package:observe/src/microtask.dart'; |
| 16 import 'package:polymer_expressions/polymer_expressions.dart'; | 17 import 'package:polymer_expressions/polymer_expressions.dart'; |
| 17 | 18 |
| 18 import 'src/utils_observe.dart' show toCamelCase, toHyphenedName; | 19 import 'src/utils_observe.dart' show toCamelCase, toHyphenedName; |
| 19 | 20 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 if (propObserver != null) { | 168 if (propObserver != null) { |
| 168 return new _PolymerBinding(this, name, model, path, propObserver); | 169 return new _PolymerBinding(this, name, model, path, propObserver); |
| 169 } | 170 } |
| 170 return super.createBinding(name, model, path); | 171 return super.createBinding(name, model, path); |
| 171 } | 172 } |
| 172 | 173 |
| 173 /** | 174 /** |
| 174 * Using Polymer's platform/src/ShadowCSS.js passing the style tag's content. | 175 * Using Polymer's platform/src/ShadowCSS.js passing the style tag's content. |
| 175 */ | 176 */ |
| 176 void _shimCss(ShadowRoot root, String localName, String extendsName) { | 177 void _shimCss(ShadowRoot root, String localName, String extendsName) { |
| 177 // TODO(terry): Remove warning, cast js.context to dynamic because of bug | 178 // TODO(terry): Need to detect if ShadowCSS.js has been loaded. Under |
| 178 // https://code.google.com/p/dart/issues/detail?id=6111. The | 179 // Dartium this wouldn't exist. However, dart:js isn't robust |
| 179 // js interop package will be patching this until bug is fixed. | 180 // to use to detect in both Dartium and dart2js if Platform is |
| 180 var platform = (js.context as dynamic).Platform; | 181 // defined. Instead in Dartium it throws an exception but in |
| 182 // dart2js it works enough to know if Platform is defined (just |
| 183 // can't be used for further derefs). This bug is described |
| 184 // https://code.google.com/p/dart/issues/detail?id=12548 |
| 185 // When fixed only use dart:js. This is necessary under |
| 186 // Dartium (no compile) we want to run w/o the JS polyfill. |
| 187 try { |
| 188 if (dartJs.context["Platform"] == null) { return; } |
| 189 } on NoSuchMethodError catch (e) { return; } |
| 190 |
| 191 var platform = js.context["Platform"]; |
| 181 if (platform == null) return; | 192 if (platform == null) return; |
| 182 var shadowCss = platform.ShadowCSS; | 193 var shadowCss = platform.ShadowCSS; |
| 183 if (shadowCss == null) return; | 194 if (shadowCss == null) return; |
| 184 | 195 |
| 185 // TODO(terry): Remove calls to shimShadowDOMStyling2 and replace with | 196 // TODO(terry): Remove calls to shimShadowDOMStyling2 and replace with |
| 186 // shimShadowDOMStyling when we support unwrapping dart:html | 197 // shimShadowDOMStyling when we support unwrapping dart:html |
| 187 // Element to a JS DOM node. | 198 // Element to a JS DOM node. |
| 188 var shimShadowDOMStyling2 = shadowCss.shimShadowDOMStyling2; | 199 var shimShadowDOMStyling2 = shadowCss.shimShadowDOMStyling2; |
| 189 if (shimShadowDOMStyling2 == null) return; | 200 if (shimShadowDOMStyling2 == null) return; |
| 190 var style = root.query('style'); | 201 var style = root.query('style'); |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 'onKeyMessage': MediaElement.keyMessageEvent, | 557 'onKeyMessage': MediaElement.keyMessageEvent, |
| 547 'onNeedKey': MediaElement.needKeyEvent, | 558 'onNeedKey': MediaElement.needKeyEvent, |
| 548 'onWebGlContextLost': CanvasElement.webGlContextLostEvent, | 559 'onWebGlContextLost': CanvasElement.webGlContextLostEvent, |
| 549 'onWebGlContextRestored': CanvasElement.webGlContextRestoredEvent, | 560 'onWebGlContextRestored': CanvasElement.webGlContextRestoredEvent, |
| 550 'onPointerLockChange': Document.pointerLockChangeEvent, | 561 'onPointerLockChange': Document.pointerLockChangeEvent, |
| 551 'onPointerLockError': Document.pointerLockErrorEvent, | 562 'onPointerLockError': Document.pointerLockErrorEvent, |
| 552 'onReadyStateChange': Document.readyStateChangeEvent, | 563 'onReadyStateChange': Document.readyStateChangeEvent, |
| 553 'onSelectionChange': Document.selectionChangeEvent, | 564 'onSelectionChange': Document.selectionChangeEvent, |
| 554 'onSecurityPolicyViolation': Document.securityPolicyViolationEvent, | 565 'onSecurityPolicyViolation': Document.securityPolicyViolationEvent, |
| 555 }; | 566 }; |
| OLD | NEW |