From bf3d050ffdcf5511a4fb0c08685ce8ba9ff61aee Mon Sep 17 00:00:00 2001 From: Eric Bidelman Date: Wed, 16 Dec 2015 16:03:49 -0800 Subject: [PATCH] Fixes demo for removal of O.o() --- bower.json | 2 +- demo/index.html | 1 + i18n-msg.html | 7 ++++++- test/basic-test.html | 6 ++++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index de8b92a..6e60a1e 100644 --- a/bower.json +++ b/bower.json @@ -22,7 +22,7 @@ "/tests/" ], "dependencies": { - "polymer": "Polymer/polymer#^1.1.4", + "polymer": "Polymer/polymer#^1.2.3", "observe-js": "Polymer/observe-js" }, "devDependencies": { diff --git a/demo/index.html b/demo/index.html index af48fd6..00e229d 100644 --- a/demo/index.html +++ b/demo/index.html @@ -33,6 +33,7 @@ // Event is only needed when running under the HTMLImports polyfill. document.addEventListener('HTMLImportsLoaded', function() { I18nMsg.lang = selector.value || document.documentElement.lang || 'en'; + Platform.performMicrotaskCheckpoint(); }); selector.addEventListener('change', function() { diff --git a/i18n-msg.html b/i18n-msg.html index 4635479..82282a2 100644 --- a/i18n-msg.html +++ b/i18n-msg.html @@ -12,12 +12,17 @@ document.addEventListener('HTMLImportsLoaded', function() { I18nMsg.lang = 'es'; // I18nMsg.url = 'locales'; // optionally use custom folder for locales. + Platform.performMicrotaskCheckpoint(); }); Note: this is done in `HTMLImportsLoaded` so `I18nMsg` will be defined by the time you set `I18nMsg.lang`. This timing is necessary under the polyfill and is not needed if the browser supports HTML Imports, natively. +Note: you must call `Platform.performMicrotaskCheckpoint()` whenever +making a change to the `I18nMsg` object. This is required due to the removal +of `Object.observe()`. + ### Message files Setting a language instructs `` to read message ids from a predefined @@ -254,7 +259,7 @@ _notifyInstances: function() { for (var i = 0, instance; instance = _instances[i]; ++i) { - instance.language = I18nMsg.lang; + instance._setLanguage(I18nMsg.lang); if (!instance.locales[instance.language][instance.msgid]) { console.warn(this.localName + ': "' + instance.msgid + '" message id was not found'); diff --git a/test/basic-test.html b/test/basic-test.html index 977eaff..187f002 100644 --- a/test/basic-test.html +++ b/test/basic-test.html @@ -40,6 +40,12 @@ assert.equal(el.language, I18nMsg.lang); }); + test('.language property is readOnly', function() { + var val = 'bogus'; + el.language = val; + assert.notEqual(el.language, val); + }); + test('.textContent was updated to localize message', function() { assert.equal(el.textContent, expected); });