Index: third_party/polymer/v0_8/components-chromium/iron-meta/iron-meta-extracted.js |
diff --git a/third_party/polymer/v0_8/components-chromium/iron-meta/iron-meta-extracted.js b/third_party/polymer/v0_8/components-chromium/iron-meta/iron-meta-extracted.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..579f9c0e290aef892e06c421d6595722c84ed34b |
--- /dev/null |
+++ b/third_party/polymer/v0_8/components-chromium/iron-meta/iron-meta-extracted.js |
@@ -0,0 +1,298 @@ |
+ |
+ |
+ (function() { |
+ |
+ // monostate data |
+ var metaDatas = {}; |
+ var metaArrays = {}; |
+ |
+ Polymer.IronMeta = Polymer({ |
+ |
+ is: 'iron-meta', |
+ |
+ properties: { |
+ |
+ /** |
+ * The type of meta-data. All meta-data of the same type is stored |
+ * together. |
+ * |
+ * @attribute type |
+ * @type String |
+ * @default 'default' |
+ */ |
+ type: { |
+ type: String, |
+ value: 'default', |
+ observer: '_typeChanged' |
+ }, |
+ |
+ /** |
+ * The key used to store `value` under the `type` namespace. |
+ * |
+ * @attribute key |
+ * @type String |
+ * @default '' |
+ */ |
+ key: { |
+ type: String, |
+ observer: '_keyChanged' |
+ }, |
+ |
+ /** |
+ * The meta-data to store or retrieve. |
+ * |
+ * @attribute value |
+ * @type * |
+ * @default this |
+ */ |
+ value: { |
+ type: Object, |
+ notify: true, |
+ observer: '_valueChanged' |
+ }, |
+ |
+ /** |
+ * If true, `value` is set to the iron-meta instance itself. |
+ * |
+ * @attribute self |
+ * @type Boolean |
+ * @default false |
+ */ |
+ self: { |
+ type: Boolean, |
+ observer: '_selfChanged' |
+ }, |
+ |
+ /** |
+ * Array of all meta-data values for the given type. |
+ * |
+ * @property list |
+ * @type Array |
+ */ |
+ list: { |
+ type: Array, |
+ notify: true |
+ } |
+ |
+ }, |
+ |
+ /** |
+ * Only runs if someone invokes the factory/constructor directly |
+ * e.g. `new Polymer.IronMeta()` |
+ */ |
+ factoryImpl: function(config) { |
+ if (config) { |
+ for (var n in config) { |
+ switch(n) { |
+ case 'type': |
+ case 'key': |
+ case 'value': |
+ this[n] = config[n]; |
+ break; |
+ } |
+ } |
+ } |
+ }, |
+ |
+ created: function() { |
+ // TODO(sjmiles): good for debugging? |
+ this._metaDatas = metaDatas; |
+ this._metaArrays = metaArrays; |
+ }, |
+ |
+ _keyChanged: function(key, old) { |
+ this._resetRegistration(old); |
+ }, |
+ |
+ _valueChanged: function(value) { |
+ this._resetRegistration(this.key); |
+ }, |
+ |
+ _selfChanged: function(self) { |
+ if (self) { |
+ this.value = this; |
+ } |
+ }, |
+ |
+ _typeChanged: function(type) { |
+ this._unregisterKey(this.key); |
+ if (!metaDatas[type]) { |
+ metaDatas[type] = {}; |
+ } |
+ this._metaData = metaDatas[type]; |
+ if (!metaArrays[type]) { |
+ metaArrays[type] = []; |
+ } |
+ this.list = metaArrays[type]; |
+ this._registerKeyValue(this.key, this.value); |
+ }, |
+ |
+ /** |
+ * Retrieves meta data value by key. |
+ * |
+ * @method byKey |
+ * @param {String} key The key of the meta-data to be returned. |
+ * @returns * |
+ */ |
+ byKey: function(key) { |
+ return this._metaData && this._metaData[key]; |
+ }, |
+ |
+ _resetRegistration: function(oldKey) { |
+ this._unregisterKey(oldKey); |
+ this._registerKeyValue(this.key, this.value); |
+ }, |
+ |
+ _unregisterKey: function(key) { |
+ this._unregister(key, this._metaData, this.list); |
+ }, |
+ |
+ _registerKeyValue: function(key, value) { |
+ this._register(key, value, this._metaData, this.list); |
+ }, |
+ |
+ _register: function(key, value, data, list) { |
+ if (key && data && value !== undefined) { |
+ data[key] = value; |
+ list.push(value); |
+ } |
+ }, |
+ |
+ _unregister: function(key, data, list) { |
+ if (key && data) { |
+ if (key in data) { |
+ var value = data[key]; |
+ delete data[key]; |
+ this.arrayDelete(list, value); |
+ } |
+ } |
+ } |
+ |
+ }); |
+ |
+ /** |
+ `iron-meta-query` can be used to access infomation stored in `iron-meta`. |
+ |
+ Examples: |
+ |
+ If I create an instance like this: |
+ |
+ <iron-meta key="info" value="foo/bar"></iron-meta> |
+ |
+ Note that keyUrl="foo/bar" is the metadata I've defined. I could define more |
+ attributes or use child nodes to define additional metadata. |
+ |
+ Now I can access that element (and it's metadata) from any `iron-meta-query` instance: |
+ |
+ var value = new Polymer.IronMetaQuery({key: 'info'}).value; |
+ |
+ @group Polymer Iron Elements |
+ @element iron-meta-query |
+ */ |
+ Polymer.IronMetaQuery = Polymer({ |
+ |
+ is: 'iron-meta-query', |
+ |
+ properties: { |
+ |
+ /** |
+ * The type of meta-data. All meta-data of the same type is stored |
+ * together. |
+ * |
+ * @attribute type |
+ * @type String |
+ * @default 'default' |
+ */ |
+ type: { |
+ type: String, |
+ value: 'default', |
+ observer: '_typeChanged' |
+ }, |
+ |
+ /** |
+ * Specifies a key to use for retrieving `value` from the `type` |
+ * namespace. |
+ * |
+ * @attribute key |
+ * @type String |
+ */ |
+ key: { |
+ type: String, |
+ observer: '_keyChanged' |
+ }, |
+ |
+ /** |
+ * The meta-data to store or retrieve. |
+ * |
+ * @attribute value |
+ * @type * |
+ * @default this |
+ */ |
+ value: { |
+ type: Object, |
+ notify: true, |
+ readOnly: true |
+ }, |
+ |
+ /** |
+ * Array of all meta-data values for the given type. |
+ * |
+ * @property list |
+ * @type Array |
+ */ |
+ list: { |
+ type: Array, |
+ notify: true |
+ } |
+ |
+ }, |
+ |
+ /** |
+ * Actually a factory method, not a true constructor. Only runs if |
+ * someone invokes it directly (via `new Polymer.IronMeta()`); |
+ */ |
+ constructor: function(config) { |
+ if (config) { |
+ for (var n in config) { |
+ switch(n) { |
+ case 'type': |
+ case 'key': |
+ this[n] = config[n]; |
+ break; |
+ } |
+ } |
+ } |
+ }, |
+ |
+ created: function() { |
+ // TODO(sjmiles): good for debugging? |
+ this._metaDatas = metaDatas; |
+ this._metaArrays = metaArrays; |
+ }, |
+ |
+ _keyChanged: function(key) { |
+ this._setValue(this._metaData && this._metaData[key]); |
+ }, |
+ |
+ _typeChanged: function(type) { |
+ this._metaData = metaDatas[type]; |
+ this.list = metaArrays[type]; |
+ if (this.key) { |
+ this._keyChanged(this.key); |
+ } |
+ }, |
+ |
+ /** |
+ * Retrieves meta data value by key. |
+ * |
+ * @method byKey |
+ * @param {String} key The key of the meta-data to be returned. |
+ * @returns * |
+ */ |
+ byKey: function(key) { |
+ return this._metaData && this._metaData[key]; |
+ } |
+ |
+ }); |
+ |
+ })(); |