From 22fc1a0c8ee1424064c8ae2c81854c8935b1a83d Mon Sep 17 00:00:00 2001 From: Ben Navetta Date: Fri, 1 Jan 2016 11:54:46 -0500 Subject: [PATCH] exit more gracefully if Polymer isn't loaded --- dist/amd/index.js | 5 +++++ dist/commonjs/index.js | 5 +++++ dist/es6/index.js | 16 +++++----------- dist/system/index.js | 5 +++++ src/index.js | 16 +++++----------- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/dist/amd/index.js b/dist/amd/index.js index 344aafc..ecb6d67 100644 --- a/dist/amd/index.js +++ b/dist/amd/index.js @@ -56,6 +56,11 @@ define(['exports', 'aurelia-framework', 'aurelia-templating-binding', 'aurelia-l } function configure(aurelia) { + if (!('Polymer' in window)) { + logger.error("Polymer is not loaded"); + return; + } + var eventManager = aurelia.container.get(_aureliaFramework.EventManager); var bindingLanguage = aurelia.container.get(_aureliaTemplatingBinding.TemplatingBindingLanguage); bindingLanguage.attributeMap['bind-value'] = 'bindValue'; diff --git a/dist/commonjs/index.js b/dist/commonjs/index.js index 9190275..ba8bf0f 100644 --- a/dist/commonjs/index.js +++ b/dist/commonjs/index.js @@ -47,6 +47,11 @@ function registerElement(eventManager, bindingLanguage, prototype) { } function configure(aurelia) { + if (!('Polymer' in window)) { + logger.error("Polymer is not loaded"); + return; + } + var eventManager = aurelia.container.get(_aureliaFramework.EventManager); var bindingLanguage = aurelia.container.get(_aureliaTemplatingBinding.TemplatingBindingLanguage); diff --git a/dist/es6/index.js b/dist/es6/index.js index b8f31d5..7416e98 100644 --- a/dist/es6/index.js +++ b/dist/es6/index.js @@ -32,6 +32,11 @@ function registerElement(eventManager, bindingLanguage, prototype) { } export function configure(aurelia){ + if (!('Polymer' in window)) { + logger.error("Polymer is not loaded"); + return; + } + let eventManager = aurelia.container.get(EventManager); let bindingLanguage = aurelia.container.get(TemplatingBindingLanguage); // let observerLocator = aurelia.container.get(ObserverLocator); @@ -49,15 +54,4 @@ export function configure(aurelia){ oldRegistrate(prototype); registerElement(eventManager, bindingLanguage, prototype); }; - - // observerLocator.getArrayObserver(registrations).subscribe(changes => { - // changes.forEach(change => { - // if (change.type === "splice" && change.addedCount > 0) { - // for (let i = 0; i < change.addedCount; i++) { - // let prototype = change.object[change.index + i - 1]; - // registerElement(eventManager, bindingLanguage, prototype); - // } - // } - // }); - // }); } diff --git a/dist/system/index.js b/dist/system/index.js index ff00194..b51b1ca 100644 --- a/dist/system/index.js +++ b/dist/system/index.js @@ -44,6 +44,11 @@ System.register(['aurelia-framework', 'aurelia-templating-binding', 'aurelia-log logger = LogManager.getLogger('polymer'); function configure(aurelia) { + if (!('Polymer' in window)) { + logger.error("Polymer is not loaded"); + return; + } + var eventManager = aurelia.container.get(EventManager); var bindingLanguage = aurelia.container.get(TemplatingBindingLanguage); bindingLanguage.attributeMap['bind-value'] = 'bindValue'; diff --git a/src/index.js b/src/index.js index b8f31d5..7416e98 100644 --- a/src/index.js +++ b/src/index.js @@ -32,6 +32,11 @@ function registerElement(eventManager, bindingLanguage, prototype) { } export function configure(aurelia){ + if (!('Polymer' in window)) { + logger.error("Polymer is not loaded"); + return; + } + let eventManager = aurelia.container.get(EventManager); let bindingLanguage = aurelia.container.get(TemplatingBindingLanguage); // let observerLocator = aurelia.container.get(ObserverLocator); @@ -49,15 +54,4 @@ export function configure(aurelia){ oldRegistrate(prototype); registerElement(eventManager, bindingLanguage, prototype); }; - - // observerLocator.getArrayObserver(registrations).subscribe(changes => { - // changes.forEach(change => { - // if (change.type === "splice" && change.addedCount > 0) { - // for (let i = 0; i < change.addedCount; i++) { - // let prototype = change.object[change.index + i - 1]; - // registerElement(eventManager, bindingLanguage, prototype); - // } - // } - // }); - // }); }