Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(634)

Side by Side Diff: lib/src/js/polymer_base_dart.html

Issue 1351693003: Update to use one less proxy per element (Closed) Base URL: git@github.com:dart-lang/polymer-dart.git@behaviors
Patch Set: update comments Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/src/js/polymer_array_methods.html ('k') | lib/src/js/polymer_bind_dart.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!-- 1 <!--
2 Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
3 for details. All rights reserved. Use of this source code is governed by a 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. 4 BSD-style license that can be found in the LICENSE file.
5 --> 5 -->
6 <script> 6 <script>
7 (function() { 7 (function() {
8 Polymer.Base.originalPolymerCreatedCallback = 8 Polymer.Base.originalPolymerCreatedCallback =
9 Polymer.Base.createdCallback; 9 Polymer.Base.createdCallback;
10 Polymer.Base.createdCallback = function() { 10 Polymer.Base.createdCallback = function() {
11 if (this.__isPolymerDart__) return; 11 if (this.__isPolymerDart__) return;
12 this.originalPolymerCreatedCallback(); 12 this.originalPolymerCreatedCallback();
13 }; 13 };
14 14
15 // Store serialize/deserialize to retain the original behavior when the
16 // methods are overriden by PolymerSerialize.
17 Polymer.Base.originalSerialize = Polymer.Base.serialize;
18 Polymer.Base.originalDeserialize = Polymer.Base.deserialize;
19
20 Polymer.Dart = {}; 15 Polymer.Dart = {};
21 16
22 // Placeholder for `undefined` return values. This should eventually go 17 // Placeholder for `undefined` return values. This should eventually go
23 // away, once we have dart:js support for `undefined`. 18 // away, once we have dart:js support for `undefined`.
24 Polymer.Dart.undefined = {}; 19 Polymer.Dart.undefined = {};
25 20
26 // Used to get an empty constructor function which doesn't call into dart. 21 // Used to get an empty constructor function which doesn't call into dart.
27 Polymer.Dart.functionFactory = function() { return function() {}; }; 22 Polymer.Dart.functionFactory = function() { return function() {}; };
28 23
29 // Generates a function which accesses a particular property on a dart 24 // Generates a function which accesses a particular property on a dart
(...skipping 25 matching lines...) Expand all
55 // recognize. 50 // recognize.
56 var args = []; 51 var args = [];
57 for (var i = 0; i < arguments.length; i++) { 52 for (var i = 0; i < arguments.length; i++) {
58 args[i] = arguments[i]; 53 args[i] = arguments[i];
59 } 54 }
60 var value = dartFunction(thisArg, args); 55 var value = dartFunction(thisArg, args);
61 if (value === Polymer.Dart.undefined) return undefined; 56 if (value === Polymer.Dart.undefined) return undefined;
62 return value; 57 return value;
63 } 58 }
64 }; 59 };
60
61 // Remove any `__dartClass__` instances during serialization.
62 Polymer.Dart.serialize = function(value, type) {
63 var dartClass = value.__dartClass__;
64 delete value.__dartClass__;
65 var serialized = Polymer.Base.serialize(value, type);
66 value.__dartClass__ = dartClass;
67 return serialized;
68 };
69
70 // TODO(jakemac): This shouldn't be necessary, but it is today
71 // https://github.com/dart-lang/sdk/issues/24371
72 Polymer.Dart.deserialize = Polymer.Base.deserialize;
73
74 Polymer.Dart.InteropBehavior = {
75 // Secret hook into property changes. Pretty hacky but its more efficient
76 // than using a JsProxy object for the element.
77 _propertyChanged: function(path, newValue, oldValue) {
78 var parts = path.split('.');
79 var thisArg = parts.length == 1 ?
80 this : this.get(parts.slice(0, parts.length - 1));
81 thisArg = thisArg.__dartClass__ || thisArg;
82 Polymer.Dart.propertyChanged(
83 thisArg, parts[parts.length - 1], newValue);
84 },
85
86 notifyPath: function(path, value, fromAbove) {
87 var notified =
88 Polymer.Base.notifyPath.call(this, path, value, fromAbove);
89 if (fromAbove) return notified;
90
91 // If you call notifyPath from dart we need to do manual modifications
92 // on any JsArray or JsObject instances.
93 var parts = this._getPathParts(path);
94 if (parts.length > 1) {
95 var model = this.get(parts.splice(0, parts.length - 1));
96 if (model[parts[0]] != value) model[parts[0]] = value;
97 }
98 return notified;
99 },
100
101 serialize: function(value, type) {
102 return Polymer.Dart.serialize(value, type);
103 }
104 }
65 })(); 105 })();
66 </script> 106 </script>
OLDNEW
« no previous file with comments | « lib/src/js/polymer_array_methods.html ('k') | lib/src/js/polymer_bind_dart.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698