diff --git a/.versions b/.versions index 5b40faf..847f8a2 100644 --- a/.versions +++ b/.versions @@ -1,56 +1,63 @@ -accounts-base@1.1.3 -babel-compiler@5.8.24_1 -babel-runtime@0.1.4 -base64@1.0.9 -binary-heap@1.0.9 -blaze@2.1.3 -blaze-tools@1.0.9 -boilerplate-generator@1.0.4 -callback-hook@1.0.9 -check@1.0.6 +accounts-base@1.3.0 +allow-deny@1.0.5 +babel-compiler@6.19.3 +babel-runtime@1.0.1 +base64@1.0.10 +binary-heap@1.0.10 +blaze@2.3.2 +blaze-tools@1.0.10 +boilerplate-generator@1.1.0 +callback-hook@1.0.10 +check@1.2.5 chuangbo:cookie@1.1.0 -ddp@1.2.2 -ddp-client@1.2.1 -ddp-common@1.2.1 -ddp-server@1.2.1 +ddp@1.2.5 +ddp-client@1.3.4 +ddp-common@1.2.8 +ddp-rate-limiter@1.0.7 +ddp-server@1.3.14 deps@1.0.12 -diff-sequence@1.0.6 -ecmascript@0.1.4 -ecmascript-collections@0.1.6 -ejson@1.0.12 -geojson-utils@1.0.4 -html-tools@1.0.10 -htmljs@1.0.10 -http@1.0.10 -id-map@1.0.8 -jquery@1.11.4 -livedata@1.0.15 -local-test:meteorhacks:fast-render@2.16.0 -localstorage@1.0.5 -logging@1.0.12 -meteor@1.1.16 -meteorhacks:fast-render@2.16.0 +diff-sequence@1.0.7 +ecmascript@0.8.0 +ecmascript-runtime@0.4.1 +ecmascript-runtime-client@0.4.2 +ecmascript-runtime-server@0.4.1 +ejson@1.0.13 +geojson-utils@1.0.10 +html-tools@1.0.11 +htmljs@1.0.11 +http@1.2.12 +id-map@1.0.9 +jquery@1.11.10 +livedata@1.0.18 +local-test:meteorspark:fast-render@2.16.1 +localstorage@1.1.0 +logging@1.1.17 +meteor@1.6.1 meteorhacks:inject-data@2.0.0 meteorhacks:meteorx@1.4.1 meteorhacks:picker@1.0.3 -minimongo@1.0.10 -mongo@1.1.2 -mongo-id@1.0.1 -npm-mongo@1.4.45 -observe-sequence@1.0.7 -ordered-dict@1.0.8 -promise@0.4.8 -random@1.0.4 -reactive-var@1.0.10 -retry@1.0.4 -routepolicy@1.0.6 -service-configuration@1.0.3 -spacebars@1.0.7 -spacebars-compiler@1.0.12 -tinytest@1.0.6 -tracker@1.0.15 -ui@1.0.8 -underscore@1.0.9 -url@1.0.10 -webapp@1.2.3 -webapp-hashing@1.0.5 +meteorspark:fast-render@2.16.1 +minimongo@1.2.0 +modules@0.9.2 +modules-runtime@0.8.0 +mongo@1.1.18 +mongo-id@1.0.6 +npm-mongo@2.2.24 +observe-sequence@1.0.16 +ordered-dict@1.0.9 +promise@0.8.9 +random@1.0.10 +rate-limit@1.0.8 +reactive-var@1.0.11 +retry@1.0.9 +routepolicy@1.0.12 +service-configuration@1.0.11 +spacebars@1.0.15 +spacebars-compiler@1.1.2 +tinytest@1.0.12 +tracker@1.1.3 +ui@1.0.13 +underscore@1.0.10 +url@1.1.0 +webapp@1.3.16 +webapp-hashing@1.0.9 diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f46fc4..fbe0f46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Change Log +### v2.16.1 + +* Fix a regression in Meteor v1.5 causing fast-render to break Meteor accounts + login/logout functionality +* Skip fast-render payload loading, if subscriptions already ready - Fixes #12 + ("Expected not to find a document already present for an add" error) + +### v2.15.0 - v2.16.0 + +LOG MISSING + ### v2.14.0 * Add support for Meteor 1.3.2 with buffered DDP. See [PR167](https://github.com/kadirahq/fast-render/pull/167) diff --git a/lib/client/auth.js b/lib/client/auth.js index e4da128..9322275 100644 --- a/lib/client/auth.js +++ b/lib/client/auth.js @@ -1,3 +1,48 @@ +if (Meteor._localStorage.setItem == window.localStorage.setItem) { + // In Meteor v1.5.0, unlike previous versions, Meteor._localStorage is a + // direct reference to window.localStorage. + // + // IE11 (earlier IE versions weren't checked) doesn't handle attempts to + // replace methods of window.localStorage with different functions properly. + // Such attempt will result in the String of the function we try to set + // saved as the function, destroying the ability to use this function. + // + // I couldn't find a way to tell in advance whether an attempt to set window.localStorage + // will result in correct function write or not (I intentionally avoid browser + // version detection, which is considered a bad practice). If such attempt will fail + // we won't have a way to restore the original function. + // + // Note 1, the situation is even worse than that. If for exapmle we'll try to set + // window.localStorage.setItem = function () {} the String value 'function () {}' + // will be saved instead of the function - not only for the current session, but + // as part of the localStorage (!) meaning that we'll have to ask users affected by + // this bug to clear the cache to fix the situation. + // + // Note 2, the following won't work: + // + // Meteor._localStorage = window.localStorage // Just to make example clear. + // originalSetItem = Meteor._localStorage.setItem + // Meteor._localStorage.setItem = function () {} + // Meteor._localStorage.setItem = originalSetItem + // + // typeof Meteor._localStorage.setItem -> string + // + // I therefore decided to bring back the original pre-Meteor v1.5.0 code of + // Meteor._localStorage below which isn't a reference to window.localStorage + + Meteor._localStorage = { + getItem: function (key) { + return window.localStorage.getItem(key); + }, + setItem: function (key, value) { + window.localStorage.setItem(key, value); + }, + removeItem: function (key) { + window.localStorage.removeItem(key); + } + }; +} + // getting tokens for the first time // Meteor calls Meteor._localStorage.setItem() on the boot // But we can do it ourselves also with this diff --git a/lib/client/fast_render.js b/lib/client/fast_render.js index e11d640..5453fb8 100644 --- a/lib/client/fast_render.js +++ b/lib/client/fast_render.js @@ -80,8 +80,14 @@ FastRender.init = function(payload) { }); }); - // If the connection supports buffered DDP writes, then flush now. - if (connection._flushBufferedWrites) connection._flushBufferedWrites(); + try { + // If the connection supports buffered DDP writes, then flush now. + if (connection._flushBufferedWrites) connection._flushBufferedWrites(); + } catch (e) { + console.info("fast-render: subscriptions already ready skip fast-render procedures"); + + return; + } // let Meteor know, user login process has been completed if(typeof Accounts != 'undefined') { diff --git a/package.js b/package.js index 4631516..71daabb 100644 --- a/package.js +++ b/package.js @@ -3,9 +3,9 @@ var path = Npm.require('path'); Package.describe({ "summary": "Render your app before the DDP connection even comes alive - magic?", - "version": "2.16.0", - "git": "https://github.com/meteorhacks/fast-render", - "name": "meteorhacks:fast-render" + "version": "2.16.1", + "git": "https://github.com/theosp/fast-render", + "name": "meteorspark:fast-render" }); Npm.depends({