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

Unified Diff: third_party/polymer/components-chromium/core-meta/core-meta-extracted.js

Issue 592593002: Inline scripts were extracted from Polymer elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/echo ""/echo/ Created 6 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 side-by-side diff with in-line comments
Download patch
Index: third_party/polymer/components-chromium/core-meta/core-meta-extracted.js
diff --git a/third_party/polymer/components-chromium/core-meta/core-meta-extracted.js b/third_party/polymer/components-chromium/core-meta/core-meta-extracted.js
new file mode 100644
index 0000000000000000000000000000000000000000..c4e60a332ca65c8bb076e165d81818b800c350d0
--- /dev/null
+++ b/third_party/polymer/components-chromium/core-meta/core-meta-extracted.js
@@ -0,0 +1,83 @@
+
+
+ (function() {
+
+ var SKIP_ID = 'meta';
+ var metaData = {}, metaArray = {};
+
+ Polymer('core-meta', {
+
+ /**
+ * The type of meta-data. All meta-data with the same type with be
+ * stored together.
+ *
+ * @attribute type
+ * @type string
+ * @default 'default'
+ */
+ type: 'default',
+
+ alwaysPrepare: true,
+
+ ready: function() {
+ this.register(this.id);
+ },
+
+ get metaArray() {
+ var t = this.type;
+ if (!metaArray[t]) {
+ metaArray[t] = [];
+ }
+ return metaArray[t];
+ },
+
+ get metaData() {
+ var t = this.type;
+ if (!metaData[t]) {
+ metaData[t] = {};
+ }
+ return metaData[t];
+ },
+
+ register: function(id, old) {
+ if (id && id !== SKIP_ID) {
+ this.unregister(this, old);
+ this.metaData[id] = this;
+ this.metaArray.push(this);
+ }
+ },
+
+ unregister: function(meta, id) {
+ delete this.metaData[id || meta.id];
+ var i = this.metaArray.indexOf(meta);
+ if (i >= 0) {
+ this.metaArray.splice(i, 1);
+ }
+ },
+
+ /**
+ * Returns a list of all meta-data elements with the same type.
+ *
+ * @property list
+ * @type array
+ * @default []
+ */
+ get list() {
+ return this.metaArray;
+ },
+
+ /**
+ * Retrieves meta-data by ID.
+ *
+ * @method byId
+ * @param {String} id The ID of the meta-data to be returned.
+ * @returns Returns meta-data.
+ */
+ byId: function(id) {
+ return this.metaData[id];
+ }
+
+ });
+
+ })();
+

Powered by Google App Engine
This is Rietveld 408576698