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

Side by Side Diff: third_party/polymer/v0_8/components/polymer/src/micro/constructor.html

Issue 1082403004: Import Polymer 0.8 and several key elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rerun reproduce.sh Created 5 years, 7 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 <!--
2 @license
3 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4 This code may only be used under the BSD style license found at http://polymer.g ithub.io/LICENSE.txt
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.txt
7 Code distributed by Google as part of the polymer project is also
8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt
9 -->
10 <script>
11
12 /**
13 * Generates a boilerplate constructor.
14 *
15 * XFoo = Polymer({
16 * is: 'x-foo'
17 * });
18 * ASSERT(new XFoo() instanceof XFoo);
19 *
20 * You can supply a custom constructor on the prototype. But remember that
21 * this constructor will only run if invoked **manually**. Elements created
22 * via `document.createElement` or from HTML _will not invoke this method_.
23 *
24 * Instead, we reuse the concept of `constructor` for a factory method which
25 * can take arguments.
26 *
27 * MyFoo = Polymer({
28 * is: 'my-foo',
29 * constructor: function(foo) {
30 * this.foo = foo;
31 * }
32 * ...
33 * });
34 *
35 * @class base feature: constructor
36 */
37
38 Polymer.Base._addFeature({
39
40 // registration-time
41
42 _prepConstructor: function() {
43 // support both possible `createElement` signatures
44 this._factoryArgs = this.extends ? [this.extends, this.is] : [this.is];
45 // thunk the constructor to delegate allocation to `createElement`
46 var ctor = function() {
47 return this._factory(arguments);
48 };
49 if (this.hasOwnProperty('extends')) {
50 ctor.extends = this.extends;
51 }
52 // ensure constructor is set. The `constructor` property is
53 // not writable on Safari; note: Chrome requires the property
54 // to be configurable.
55 Object.defineProperty(this, 'constructor', {value: ctor,
56 writable: true, configurable: true});
57 ctor.prototype = this;
58 },
59
60 _factory: function(args) {
61 var elt = document.createElement.apply(document, this._factoryArgs);
62 if (this.factoryImpl) {
63 this.factoryImpl.apply(elt, args);
64 }
65 return elt;
66 }
67
68 });
69
70 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698