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

Side by Side Diff: packages/polymer_interop/lib/src/polymer_proxy_mixin.dart

Issue 2312183003: Removed Polymer from Observatory deps (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4 library polymer_interop.src.js_element_proxy;
5
6 import 'dart:html' show Element, DocumentFragment;
7 import 'dart:js' as js;
8 import 'package:web_components/web_components.dart'
9 show CustomElementProxyMixin;
10
11 /// A mixin to make it easier to interoperate with Polymer JS elements. This
12 /// exposes only a subset of the public api that is most useful from external
13 /// elements.
14 ///
15 /// Since mixins can't mixin or extend other mixins, you must also
16 /// mixin the [CustomElementProxyMixin] class from `web_components`. The
17 /// implements statement here enforces that.
18 abstract class PolymerProxyMixin implements CustomElementProxyMixin {
19 /// The underlying Js Element's `$` property.
20 js.JsObject get $ => jsElement[r'$'];
21
22 /// By default the data bindings will be cleaned up when this custom element
23 /// is detached from the document. Overriding this to return `true` will
24 /// prevent that from happening.
25 bool get preventDispose => jsElement['preventDispose'];
26 set preventDispose(bool newValue) => jsElement['preventDispose'] = newValue;
27
28 /// Force any pending property changes to synchronously deliver to handlers
29 /// specified in the `observe` object. Note, normally changes are processed at
30 /// microtask time.
31 ///
32 // Dart note: renamed to `deliverPropertyChanges` to be more consistent with
33 // other polymer.dart elements.
34 void deliverPropertyChanges() {
35 jsElement.callMethod('deliverChanges', []);
36 }
37
38 /// Inject HTML which contains markup bound to this element into a target
39 /// element (replacing target element content).
40 DocumentFragment injectBoundHTML(String html, [Element element]) =>
41 jsElement.callMethod('injectBoundHTML', [html, element]);
42
43 /// Creates dom cloned from the given template, instantiating bindings with
44 /// this element as the template model and `PolymerExpressions` as the binding
45 /// delegate.
46 DocumentFragment instanceTemplate(Element template) =>
47 jsElement.callMethod('instanceTemplate', [template]);
48
49 /// This method should rarely be used and only if `cancelUnbindAll` has been
50 /// called to prevent element unbinding. In this case, the element's bindings
51 /// will not be automatically cleaned up and it cannot be garbage collected by
52 /// by the system. If memory pressure is a concern or a large amount of
53 /// elements need to be managed in this way, `unbindAll` can be called to
54 /// deactivate the element's bindings and allow its memory to be reclaimed.
55 void unbindAll() => jsElement.callMethod('unbindAll', []);
56
57 /// Call in `detached` to prevent the element from unbinding when it is
58 /// detached from the dom. The element is unbound as a cleanup step that
59 /// allows its memory to be reclaimed. If `cancelUnbindAll` is used, consider
60 ///calling `unbindAll` when the element is no longer needed. This will allow
61 ///its memory to be reclaimed.
62 void cancelUnbindAll() => jsElement.callMethod('cancelUnbindAll', []);
63 }
OLDNEW
« no previous file with comments | « packages/polymer_interop/lib/src/js/polymer.min.js ('k') | packages/polymer_interop/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698