OLD | NEW |
---|---|
1 <!-- | |
2 Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
Siggi Cherem (dart-lang)
2015/08/13 18:52:41
+1 :)
jakemac
2015/08/13 19:14:29
Done.
| |
3 for details. All rights reserved. Use of this source code is governed by a | |
4 BSD-style license that can be found in the LICENSE file. | |
5 --> | |
1 <script> | 6 <script> |
2 if (Polymer.Bind) { | 7 if (Polymer.Bind) { |
3 // Overwrite prepareInstance to a no-op for dart elements. | 8 // Overwrite prepareInstance to a no-op for dart elements. |
4 Polymer.Bind._originalPrepareInstance = Polymer.Bind.prepareInstance; | 9 Polymer.Bind._originalPrepareInstance = Polymer.Bind.prepareInstance; |
5 Polymer.Bind.prepareInstance = function (inst) { | 10 Polymer.Bind.prepareInstance = function (inst) { |
6 if (inst.__isPolymerDart__) return; | 11 if (inst.__isPolymerDart__) return; |
7 this._originalPrepareInstance(inst); | 12 this._originalPrepareInstance(inst); |
8 } | 13 }; |
9 | 14 |
10 // We always need to create property accessors for dart elements, because we | 15 // We always need to create property accessors for dart elements, because we |
11 // always have `effects` (updating the dart class). | 16 // always have `effects` (updating the dart class). |
12 // TODO(jakemac): Investigate making the updating of the dart class be an | 17 // TODO(jakemac): Investigate making the updating of the dart class be an |
13 // actual `effect` so that we don't have to do this hack. | 18 // actual `effect` so that we don't have to do this hack. |
14 Polymer.Bind.oldCreateBindings = Polymer.Bind.createBindings; | 19 Polymer.Bind.oldCreateBindings = Polymer.Bind.createBindings; |
15 Polymer.Bind.createBindings = function(model) { | 20 Polymer.Bind.createBindings = function(model) { |
16 if (!model.__isPolymerDart__) { | 21 if (!model.__isPolymerDart__) { |
17 this.oldCreateBindings(model); | 22 this.oldCreateBindings(model); |
18 return; | 23 return; |
19 } | 24 } |
20 | 25 |
21 // map of properties to effects | 26 // map of properties to effects |
22 var fx$ = model._propertyEffects || {}; | 27 var fx$ = model._propertyEffects || {}; |
23 var p$ = model.properties; | 28 var p$ = model.properties; |
24 // for each property with effects | 29 |
25 for (var n in p$) { | 30 // The union of the keys in fx$ and p$ (fx$ might contain properties from |
31 // js behaviors, which don't appear in p$). | |
32 var allProperties = {}; | |
33 for (var key in p$) { | |
34 allProperties[key] = true; | |
35 } | |
36 for (var key in fx$) { | |
37 allProperties[key] = true; | |
38 } | |
39 | |
40 // for each dart property (with or without effects) and each js property | |
41 // with effects | |
42 for (var n in allProperties) { | |
26 // array of effects | 43 // array of effects |
27 var fx = fx$[n]; | 44 var fx = fx$[n]; |
28 // effects have priority | 45 // effects have priority |
29 if (fx) { | 46 if (fx) { |
30 fx.sort(this._sortPropertyEffects); | 47 fx.sort(this._sortPropertyEffects); |
31 } | 48 } |
32 // create accessors | 49 // create accessors |
33 this._createAccessors(model, n, fx); | 50 this._createAccessors(model, n, fx); |
34 } | 51 } |
35 }; | 52 }; |
36 } | 53 } |
37 </script> | 54 </script> |
OLD | NEW |