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

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

Issue 1215543002: Remove Polymer 0.5. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unit test Created 5 years, 6 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-shared-lib/core-shared-lib-extracted.js
diff --git a/third_party/polymer/components-chromium/core-shared-lib/core-shared-lib-extracted.js b/third_party/polymer/components-chromium/core-shared-lib/core-shared-lib-extracted.js
deleted file mode 100644
index cfb46066f9c0cf61302400fc29a239636196c522..0000000000000000000000000000000000000000
--- a/third_party/polymer/components-chromium/core-shared-lib/core-shared-lib-extracted.js
+++ /dev/null
@@ -1,116 +0,0 @@
-
-(function() {
-
- Polymer('core-shared-lib',{
-
- notifyEvent: 'core-shared-lib-load',
-
- ready: function() {
- if (!this.url && this.defaultUrl) {
- this.url = this.defaultUrl;
- }
- },
-
- urlChanged: function() {
- require(this.url, this, this.callbackName);
- },
-
- provide: function() {
- this.async('notify');
- },
-
- notify: function() {
- this.fire(this.notifyEvent, arguments);
- }
-
- });
-
- var apiMap = {};
-
- function require(url, notifiee, callbackName) {
- // make hashable string form url
- var name = nameFromUrl(url);
- // lookup existing loader instance
- var loader = apiMap[name];
- // create a loader as needed
- if (!loader) {
- loader = apiMap[name] = new Loader(name, url, callbackName);
- }
- loader.requestNotify(notifiee);
- }
-
- function nameFromUrl(url) {
- return url.replace(/[\:\/\%\?\&\.\=\-\,]/g, '_') + '_api';
- }
-
- var Loader = function(name, url, callbackName) {
- this.instances = [];
- this.callbackName = callbackName;
- if (this.callbackName) {
- window[this.callbackName] = this.success.bind(this);
- } else {
- if (url.indexOf(this.callbackMacro) >= 0) {
- this.callbackName = name + '_loaded';
- window[this.callbackName] = this.success.bind(this);
- url = url.replace(this.callbackMacro, this.callbackName);
- } else {
- // TODO(sjmiles): we should probably fallback to listening to script.load
- throw 'core-shared-api: a %%callback%% parameter is required in the API url';
- }
- }
- //
- this.addScript(url);
- };
-
- Loader.prototype = {
-
- callbackMacro: '%%callback%%',
- loaded: false,
-
- addScript: function(src) {
- var script = document.createElement('script');
- script.src = src;
- script.onerror = this.error.bind(this);
- var s = document.querySelector('script');
- s.parentNode.insertBefore(script, s);
- this.script = script;
- },
-
- removeScript: function() {
- if (this.script.parentNode) {
- this.script.parentNode.removeChild(this.script);
- }
- this.script = null;
- },
-
- error: function() {
- this.cleanup();
- },
-
- success: function() {
- this.loaded = true;
- this.cleanup();
- this.result = Array.prototype.slice.call(arguments);
- this.instances.forEach(this.provide, this);
- this.instances = null;
- },
-
- cleanup: function() {
- delete window[this.callbackName];
- },
-
- provide: function(instance) {
- instance.notify(instance, this.result);
- },
-
- requestNotify: function(instance) {
- if (this.loaded) {
- this.provide(instance);
- } else {
- this.instances.push(instance);
- }
- }
-
- };
-
-})();

Powered by Google App Engine
This is Rietveld 408576698