Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fast-render break Meteor v1.5 under IE11 bugfix #191

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 58 additions & 51 deletions .versions
Original file line number Diff line number Diff line change
@@ -1,56 +1,63 @@
[email protected]
[email protected]_1
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
chuangbo:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
local-test:meteorhacks:[email protected]
[email protected]
[email protected]
[email protected]
meteorhacks:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
local-test:meteorspark:[email protected]
[email protected]
[email protected]
[email protected]
meteorhacks:[email protected]
meteorhacks:[email protected]
meteorhacks:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
meteorspark:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
45 changes: 45 additions & 0 deletions lib/client/auth.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 8 additions & 2 deletions lib/client/fast_render.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
6 changes: 3 additions & 3 deletions package.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down