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

Side by Side Diff: lib/src/common/polymer_serialize.dart

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/common/polymer_mixin.dart ('k') | lib/src/js/polymer_array_methods.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 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 library polymer.src.common.polymer_serialize; 4 library polymer.src.common.polymer_serialize;
5 5
6 import 'dart:js'; 6 import 'dart:js';
7 import 'js_proxy.dart'; 7 import 'js_proxy.dart';
8 import 'polymer_mixin.dart'; 8 import 'polymer_mixin.dart';
9 import 'polymer_descriptor.dart'; 9 import 'polymer_descriptor.dart';
10 10
11 /// Mixin for Polymer serialization methods. 11 /// Mixin for Polymer serialization methods.
12 /// 12 ///
13 /// This should only be used if the [serialize] and [deserialize] methods need 13 /// This should only be used if the [serialize] and [deserialize] methods need
14 /// to be overridden to support additional Dart types. Any types not explicitly 14 /// to be overridden to support additional Dart types. Any types not explicitly
15 /// handled by the overridden method should defer to the original method by 15 /// handled by the overridden method should defer to the original method by
16 /// calling the base class's implementation. 16 /// calling the base class's implementation.
17 abstract class PolymerSerialize implements PolymerMixin { 17 abstract class PolymerSerialize implements PolymerMixin {
18 JsObject get jsElement; 18 JsObject get jsElement;
19 19
20 /// Serializes the [value] into a [String]. 20 /// Serializes the [value] into a [String].
21 String serialize(Object value) { 21 String serialize(value) {
22 var result = jsElement.callMethod('originalSerialize', [jsValue(value)]); 22 var result = _polymerDartSerialize.apply([jsValue(value)]);
23 23
24 return (result != null) ? result.toString() : null; 24 return (result != null) ? result.toString() : null;
25 } 25 }
26 26
27 /// Deserializes the [value] into an object of the given [type]. 27 /// Deserializes the [value] into an object of the given [type].
28 dynamic deserialize(String value, Type type) { 28 dynamic deserialize(String value, Type type) {
29 return dartValue(jsElement.callMethod( 29 return dartValue(_polymerDartDeserialize.apply([value, jsType(type)]));
30 'originalDeserialize', [jsValue(value), jsType(type)]));
31 } 30 }
32 } 31 }
32
33 final JsObject _polymer = context['Polymer'];
34 final JsFunction _polymerDartSerialize = _polymer['Dart']['serialize'];
35 final JsFunction _polymerDartDeserialize = _polymer['Dart']['deserialize'];
OLDNEW
« no previous file with comments | « lib/src/common/polymer_mixin.dart ('k') | lib/src/js/polymer_array_methods.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698