From 8fd039334db9606d5d0276bb092d26b31c9daf7b Mon Sep 17 00:00:00 2001 From: andipavllo Date: Fri, 10 Jul 2015 14:53:31 +0900 Subject: [PATCH 01/11] fix($onsen): read-only variables fix, fixes #767 --- framework/services/onsen.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/framework/services/onsen.js b/framework/services/onsen.js index 95839a6c9c..f92cea6338 100644 --- a/framework/services/onsen.js +++ b/framework/services/onsen.js @@ -62,7 +62,7 @@ limitations under the License. return element[methodName].apply(element, arguments); }; }); - + return function() { methodNames.forEach(function(methodName) { view[methodName] = null; @@ -163,7 +163,7 @@ limitations under the License. deferred.resolve(this.normalizePageHTML(html)); return deferred.promise; - + } else { return $http({ url: page, @@ -186,7 +186,7 @@ limitations under the License. if (!html.match(/^<(ons-page|ons-navigator|ons-tabbar|ons-sliding-menu|ons-split-view)/)) { html = '' + html + ''; } - + return html; }, @@ -195,7 +195,7 @@ limitations under the License. * * @param {Object} attrs * @param {Array} [modifiers] an array of appendix modifier - * @return {Function} + * @return {Function} */ generateModifierTemplater: function(attrs, modifiers) { var attrModifiers = attrs && typeof attrs.modifier === 'string' ? attrs.modifier.trim().split(/ +/) : []; @@ -216,7 +216,7 @@ limitations under the License. * Add modifier methods to view object for custom elements. * * @param {Object} view object - * @param {jqLite} element + * @param {jqLite} element */ addModifierMethodsForCustomElements: function(view, element) { var methods = { @@ -268,7 +268,7 @@ limitations under the License. * * @param {Object} view object * @param {String} template - * @param {jqLite} element + * @param {jqLite} element */ addModifierMethods: function(view, template, element) { var _tr = function(modifier) { @@ -285,7 +285,7 @@ limitations under the License. }, addModifier: function(modifier) { - element.addClass(_tr(modifier)); + element.addClass(_tr(modifier)); }, setModifier: function(modifier) { @@ -306,7 +306,7 @@ limitations under the License. toggleModifier: function(modifier) { var cls = _tr(modifier); if (element.hasClass(cls)) { - element.removeClass(cls); + element.removeClass(cls); } else { element.addClass(cls); } @@ -469,6 +469,10 @@ limitations under the License. } container[names[names.length - 1]] = object; + + if (container[names[names.length -1]] !== object) { + throw new Error('You cannot set var="' + object._attrs.var + '" because it\'s already a \'window\' read-only attribute.'); + } } if (ons.componentBase) { From 9712b219eb4e02077489e9d1d9ade460420517b3 Mon Sep 17 00:00:00 2001 From: Andreas Argelius Date: Mon, 13 Jul 2015 12:52:36 +0900 Subject: [PATCH 02/11] (ons._internal): Call callback with error on non-successful status code. --- core/lib/ons-internal.es6 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/lib/ons-internal.es6 b/core/lib/ons-internal.es6 index a1ec8b424a..b8db806134 100644 --- a/core/lib/ons-internal.es6 +++ b/core/lib/ons-internal.es6 @@ -128,8 +128,14 @@ limitations under the License. var xhr = new XMLHttpRequest(); xhr.open('GET', page, true); xhr.onload = function(response) { - var html = xhr.responseText; - callback(null, normalizePageHTML(html), xhr); + var html = xhr.responseText, + error = null; + + if (xhr.status >= 400 && xhr.status < 600) { + error = xhr.status; + } + + callback(error, normalizePageHTML(html), xhr); }; xhr.onerror = function() { callback(xhr.status, null, xhr); From c2b3950154a774efd5db17a7fa18a0e260ef7e6f Mon Sep 17 00:00:00 2001 From: andipavllo Date: Tue, 14 Jul 2015 16:12:48 +0900 Subject: [PATCH 03/11] fix(ons-switch): fixed checked attribute behavior, fixes #775 --- core/elements/ons-switch.es6 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/elements/ons-switch.es6 b/core/elements/ons-switch.es6 index 0dc0970a35..c242863186 100644 --- a/core/elements/ons-switch.es6 +++ b/core/elements/ons-switch.es6 @@ -58,6 +58,7 @@ limitations under the License. } else { this.removeAttribute('checked'); } + this._updateForCheckedAttribute(); } get disabled() { @@ -111,14 +112,14 @@ limitations under the License. } attachedCallback() { - this._getCheckbox().addEventListener('change', this._onChangeListener); + this.addEventListener('change', this._onChangeListener); } _onChangeListener() { if (this.checked !== true) { - this.parentNode.removeAttribute('checked'); + this.removeAttribute('checked'); } else { - this.parentNode.setAttribute('checked', ''); + this.setAttribute('checked', ''); } } From 9523e6160a05cb6bdbcdbf71963ddc62a628b046 Mon Sep 17 00:00:00 2001 From: andipavllo Date: Tue, 14 Jul 2015 16:17:51 +0900 Subject: [PATCH 04/11] fix(ons-switch): fixed wrong eventListener target --- core/elements/ons-switch.es6 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/elements/ons-switch.es6 b/core/elements/ons-switch.es6 index c242863186..c25ee54978 100644 --- a/core/elements/ons-switch.es6 +++ b/core/elements/ons-switch.es6 @@ -112,7 +112,7 @@ limitations under the License. } attachedCallback() { - this.addEventListener('change', this._onChangeListener); + this.getCheckbox().addEventListener('change', this._onChangeListener); } _onChangeListener() { From 5f799b0b52050372dd0bc689e95732ddd6f39290 Mon Sep 17 00:00:00 2001 From: Andi Pavllo Date: Tue, 14 Jul 2015 16:36:43 +0900 Subject: [PATCH 05/11] style(ons-switch): added missing underscore --- core/elements/ons-switch.es6 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/elements/ons-switch.es6 b/core/elements/ons-switch.es6 index c25ee54978..20ab6aa5bd 100644 --- a/core/elements/ons-switch.es6 +++ b/core/elements/ons-switch.es6 @@ -112,7 +112,7 @@ limitations under the License. } attachedCallback() { - this.getCheckbox().addEventListener('change', this._onChangeListener); + this._getCheckbox().addEventListener('change', this._onChangeListener); } _onChangeListener() { From eb00e9b70113a6078d7932937ca8c9badcef91ff Mon Sep 17 00:00:00 2001 From: Andreas Argelius Date: Tue, 14 Jul 2015 18:43:50 +0900 Subject: [PATCH 06/11] style($onsen): Change error message. --- framework/services/onsen.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/services/onsen.js b/framework/services/onsen.js index f92cea6338..3ab6a4a7e9 100644 --- a/framework/services/onsen.js +++ b/framework/services/onsen.js @@ -471,7 +471,7 @@ limitations under the License. container[names[names.length - 1]] = object; if (container[names[names.length -1]] !== object) { - throw new Error('You cannot set var="' + object._attrs.var + '" because it\'s already a \'window\' read-only attribute.'); + throw new Error('Cannot set var="' + object._attrs.var + '" because it will overwrite a read-only variable.'); } } From ad398f25b141d4f9c3b60f8f3ee74d5dc83d8570 Mon Sep 17 00:00:00 2001 From: andipavllo Date: Tue, 14 Jul 2015 19:01:19 +0900 Subject: [PATCH 07/11] style(onsen.js): removed empty spaces --- framework/js/onsen.js | 46 +++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/framework/js/onsen.js b/framework/js/onsen.js index e03a109faa..5fcbfa63cc 100644 --- a/framework/js/onsen.js +++ b/framework/js/onsen.js @@ -19,7 +19,7 @@ limitations under the License. * @ngdoc object * @name ons * @category util - * @description + * @description * [ja]Onsen UIで利用できるグローバルなオブジェクトです。このオブジェクトは、AngularJSのスコープから参照することができます。 [/ja] * [en]A global object that's used in Onsen UI. This object can be reached from the AngularJS scope.[/en] */ @@ -27,7 +27,7 @@ limitations under the License. /** * @ngdoc method * @signature ready(callback) - * @description + * @description * [ja]アプリの初期化に利用するメソッドです。渡された関数は、Onsen UIの初期化が終了している時点で必ず呼ばれます。[/ja] * [en]Method used to wait for app initialization. The callback will not be executed until Onsen UI has been completely initialized.[/en] * @param {Function} callback @@ -38,13 +38,13 @@ limitations under the License. /** * @ngdoc method * @signature bootstrap([moduleName, [dependencies]]) - * @description + * @description * [ja]Onsen UIの初期化を行います。Angular.jsのng-app属性を利用すること無しにOnsen UIを読み込んで初期化してくれます。[/ja] * [en]Initialize Onsen UI. Can be used to load Onsen UI without using the ng-app attribute from AngularJS.[/en] - * @param {String} [moduleName] + * @param {String} [moduleName] * [en]AngularJS module name.[/en] * [ja]Angular.jsでのモジュール名[/ja] - * @param {Array} [dependencies] + * @param {Array} [dependencies] * [en]List of AngularJS module dependencies.[/en] * [ja]依存するAngular.jsのモジュール名の配列[/ja] * @return {Object} @@ -55,7 +55,7 @@ limitations under the License. /** * @ngdoc method * @signature enableAutoStatusBarFill() - * @description + * @description * [en]Enable status bar fill feature on iOS7 and above.[/en] * [ja]iOS7以上で、ステータスバー部分の高さを自動的に埋める処理を有効にします。[/ja] */ @@ -63,7 +63,7 @@ limitations under the License. /** * @ngdoc method * @signature disableAutoStatusBarFill() - * @description + * @description * [en]Disable status bar fill feature on iOS7 and above.[/en] * [ja]iOS7以上で、ステータスバー部分の高さを自動的に埋める処理を無効にします。[/ja] */ @@ -96,7 +96,7 @@ limitations under the License. * @return {Object} * [en]Component object. Will return null if no component was found.[/en] * [ja]コンポーネントのオブジェクトを返します。もしコンポーネントが見つからなかった場合にはnullを返します。[/ja] - * @description + * @description * [en]Find parent component object of dom element.[/en] * [ja]指定されたdom引数の親要素をたどってコンポーネントを検索します。[/ja] */ @@ -113,7 +113,7 @@ limitations under the License. * @return {Object} * [en]Component object. Will return null if no component was found.[/en] * [ja]コンポーネントのオブジェクトを返します。もしコンポーネントが見つからなかった場合にはnullを返します。[/ja] - * @description + * @description * [en]Find component object using CSS selector.[/en] * [ja]CSSセレクタを使ってコンポーネントのオブジェクトを検索します。[/ja] */ @@ -121,10 +121,10 @@ limitations under the License. /** * @ngdoc method * @signature setDefaultDeviceBackButtonListener(listener) - * @param {Function} listener + * @param {Function} listener * [en]Function that executes when device back button is pressed.[/en] * [ja]デバイスのバックボタンが押された時に実行される関数オブジェクトを指定します。[/ja] - * @description + * @description * [en]Set default handler for device back button.[/en] * [ja]デバイスのバックボタンのためのデフォルトのハンドラを設定します。[/ja] */ @@ -132,7 +132,7 @@ limitations under the License. /** * @ngdoc method * @signature disableDeviceBackButtonHandler() - * @description + * @description * [en]Disable device back button event handler.[/en] * [ja]デバイスのバックボタンのイベントを受け付けないようにします。[/ja] */ @@ -140,7 +140,7 @@ limitations under the License. /** * @ngdoc method * @signature enableDeviceBackButtonHandler() - * @description + * @description * [en]Enable device back button event handler.[/en] * [ja]デバイスのバックボタンのイベントを受け付けるようにします。[/ja] */ @@ -151,7 +151,7 @@ limitations under the License. * @return {Boolean} * [en]Will be true if Onsen UI is initialized.[/en] * [ja]初期化されているかどうかを返します。[/ja] - * @description + * @description * [en]Returns true if Onsen UI is initialized.[/en] * [ja]Onsen UIがすでに初期化されているかどうかを返すメソッドです。[/ja] */ @@ -162,7 +162,7 @@ limitations under the License. * @param {HTMLElement} dom * [en]Element to compile.[/en] * [ja]コンパイルする要素を指定します。[/ja] - * @description + * @description * [en]Compile Onsen UI components.[/en] * [ja]通常のHTMLの要素をOnsen UIのコンポーネントにコンパイルします。[/ja] */ @@ -173,7 +173,7 @@ limitations under the License. * @return {Boolean} * [en]Will be true if the app is running in Cordova.[/en] * [ja]Cordovaで実行されている場合にtrueになります。[/ja] - * @description + * @description * [en]Returns true if running inside Cordova.[/en] * [ja]Cordovaで実行されているかどうかを返すメソッドです。[/ja] */ @@ -193,7 +193,7 @@ limitations under the License. * @return {Promise} * [en]Promise object that resolves to the alert dialog component object.[/en] * [ja]ダイアログのコンポーネントオブジェクトを解決するPromiseオブジェクトを返します。[/ja] - * @description + * @description * [en]Create a alert dialog instance from a template.[/en] * [ja]テンプレートからアラートダイアログのインスタンスを生成します。[/ja] */ @@ -213,7 +213,7 @@ limitations under the License. * @return {Promise} * [en]Promise object that resolves to the dialog component object.[/en] * [ja]ダイアログのコンポーネントオブジェクトを解決するPromiseオブジェクトを返します。[/ja] - * @description + * @description * [en]Create a dialog instance from a template.[/en] * [ja]テンプレートからダイアログのインスタンスを生成します。[/ja] */ @@ -233,7 +233,7 @@ limitations under the License. * @return {Promise} * [en]Promise object that resolves to the popover component object.[/en] * [ja]ポップオーバーのコンポーネントオブジェクトを解決するPromiseオブジェクトを返します。[/ja] - * @description + * @description * [en]Create a popover instance from a template.[/en] * [ja]テンプレートからポップオーバーのインスタンスを生成します。[/ja] */ @@ -446,7 +446,7 @@ limitations under the License. // Copy attributes and insert html. var attrs = el.prop('attributes'); for (var i = 0, l = attrs.length; i < l; i++) { - alertDialog.attr(attrs[i].name, attrs[i].value); + alertDialog.attr(attrs[i].name, attrs[i].value); } alertDialog.html(el.html()); @@ -492,7 +492,7 @@ limitations under the License. // Copy attributes and insert html. var attrs = el.prop('attributes'); for (var i = 0, l = attrs.length; i < l; i++) { - dialog.attr(attrs[i].name, attrs[i].value); + dialog.attr(attrs[i].name, attrs[i].value); } dialog.html(el.html()); @@ -517,8 +517,8 @@ limitations under the License. childStyle = child.getAttribute('style'), newStyle = (function(a, b) { var c = - (a.substr(-1) === ';' ? a : a + ';') + - (b.substr(-1) === ';' ? b : b + ';'); + (a.substr(-1) === ';' ? a : a + ';') + + (b.substr(-1) === ';' ? b : b + ';'); return c; })(parentStyle, childStyle); From 3f68dc2298d8c7ca4eece9924ee0e47539fa801c Mon Sep 17 00:00:00 2001 From: andipavllo Date: Tue, 14 Jul 2015 19:04:40 +0900 Subject: [PATCH 08/11] fix(onsenui.js): fixed ons.bootstrap() on Windows, fixes #777 --- framework/js/onsen.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/js/onsen.js b/framework/js/onsen.js index 5fcbfa63cc..813171f3f7 100644 --- a/framework/js/onsen.js +++ b/framework/js/onsen.js @@ -327,7 +327,7 @@ limitations under the License. var module = angular.module(name, deps); var doc = window.document; - if (doc.readyState == 'loading' || doc.readyState == 'uninitialized') { + if (doc.readyState == 'loading' || doc.readyState == 'uninitialized' || doc.readyState == 'interactive') { doc.addEventListener('DOMContentLoaded', function() { angular.bootstrap(doc.documentElement, [name]); }, false); From 136a84cbd848bfb7e37db7161500b739c842b221 Mon Sep 17 00:00:00 2001 From: Andreas Argelius Date: Wed, 15 Jul 2015 19:00:10 +0900 Subject: [PATCH 09/11] chore(circle.yml): CircleCI will be succesful even if Coveralls fails. --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 9fb53eb516..b112eb59d1 100644 --- a/circle.yml +++ b/circle.yml @@ -16,4 +16,4 @@ test: post: - mkdir -p $CIRCLE_TEST_REPORTS/junit/ - find . -type f -regex "./core/test/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \; - - cat ./core/test/coverage/*/lcov.info | coveralls + - cat ./core/test/coverage/*/lcov.info | coveralls || true # Ignore if this fails. From ab7ec25aeaa61f1a9eda7756009471d683caf33e Mon Sep 17 00:00:00 2001 From: Andreas Argelius Date: Wed, 15 Jul 2015 19:02:13 +0900 Subject: [PATCH 10/11] fix(ons._internal): Revert invalid fix. --- core/lib/ons-internal.es6 | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/core/lib/ons-internal.es6 b/core/lib/ons-internal.es6 index b8db806134..a1ec8b424a 100644 --- a/core/lib/ons-internal.es6 +++ b/core/lib/ons-internal.es6 @@ -128,14 +128,8 @@ limitations under the License. var xhr = new XMLHttpRequest(); xhr.open('GET', page, true); xhr.onload = function(response) { - var html = xhr.responseText, - error = null; - - if (xhr.status >= 400 && xhr.status < 600) { - error = xhr.status; - } - - callback(error, normalizePageHTML(html), xhr); + var html = xhr.responseText; + callback(null, normalizePageHTML(html), xhr); }; xhr.onerror = function() { callback(xhr.status, null, xhr); From 178741843b14f7cbbd14c75a0aa96afed86a302e Mon Sep 17 00:00:00 2001 From: Andi Pavllo Date: Wed, 15 Jul 2015 19:29:08 +0900 Subject: [PATCH 11/11] docs(CHANGELOG): added bug fix --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 523f7c1861..fec1dd2191 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,8 @@ v1.3.5-dev * ons-icon: Fixed [#688](https://github.com/OnsenUI/OnsenUI/issues/688). * ons-page: Added page life cycle events. * ons-list-item: Added `lock-on-drag` attribute to prevent vertical scrolling when user pans left or right. + * core: Fixed [#777](https://github.com/OnsenUI/OnsenUI/issues/777). + * core: Fixed [#767](https://github.com/OnsenUI/OnsenUI/issues/767). v1.3.4 ----