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

Side by Side Diff: third_party/polymer/v0_8/components/polymer/src/micro/extends.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, 8 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 * Support `extends` property (for type-extension only).
14 *
15 * If the mixin is String-valued, the corresponding Polymer module
16 * is mixed in.
17 *
18 * Polymer({
19 * is: 'pro-input',
20 * extends: 'input',
21 * ...
22 * });
23 *
24 * Type-extension objects are created using `is` notation in HTML, or via
25 * the secondary argument to `document.createElement` (the type-extension
26 * rules are part of the Custom Elements specification, not something
27 * created by Polymer).
28 *
29 * Example:
30 *
31 * <!-- right: creates a pro-input element -->
32 * <input is="pro-input">
33 *
34 * <!-- wrong: creates an unknown element -->
35 * <pro-input>
36 *
37 * <script>
38 * // right: creates a pro-input element
39 * var elt = document.createElement('input', 'pro-input');
40 *
41 * // wrong: creates an unknown element
42 * var elt = document.createElement('pro-input');
43 * <\script>
44 *
45 * @class base feature: extends
46 */
47
48 Polymer.Base._addFeature({
49
50 _prepExtends: function() {
51 if (this.extends) {
52 this.__proto__ = this.getExtendedPrototype(this.extends);
53 }
54 },
55
56 getExtendedPrototype: function(tag) {
57 return this.getExtendedNativePrototype(tag);
58 },
59
60 nativePrototypes: {}, // static
61
62 getExtendedNativePrototype: function(tag) {
63 var p = this.nativePrototypes[tag];
64 if (!p) {
65 var np = this.getNativePrototype(tag);
66 p = this.extend(Object.create(np), Polymer.Base);
67 this.nativePrototypes[tag] = p;
68 }
69 return p;
70 },
71
72 getNativePrototype: function(tag) {
73 // TODO(sjmiles): sad necessity
74 return Object.getPrototypeOf(document.createElement(tag));
75 }
76
77 });
78
79 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698