Skip to content

Commit

Permalink
knockout 3.5.0 compatibility
Browse files Browse the repository at this point in the history
Knockout 3.5.0 does something different with style binding so we have some rgb(255,0,0) instead of red. The "compatibility test" shouldn't care about this differences, so let's just use the attr binding.
  • Loading branch information
bago committed Mar 31, 2019
1 parent 2548c2a commit e8d6f60
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/js/bindings/if-subs.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ if (typeof ko.subscription == 'function' && typeof ko.isWritableObservable !== '
} else if (ko.version == "3.4.2") {
beforeSubscriptionProp = 'ua';
afterSubscriptionProp = 'Ka';
} else if (ko.version == "3.5.0-beta") {
beforeSubscriptionProp = 'Pa';
afterSubscriptionProp = 'ab';
} else if (ko.version == "3.5.0") {
beforeSubscriptionProp = 'Qa';
afterSubscriptionProp = 'cb';
}
else throw "Unsupported minimized Knockout version " + ko.version + " (supported DEBUG or minimized 3.2.0 ... 3.5.0-beta)";
else throw "Unsupported minimized Knockout version " + ko.version + " (supported DEBUG or minimized 3.2.0 ... 3.5.0)";

// internally used by ifsubs binding.
// WARNING this break when used with pureComputed or deferredEvaluated
Expand Down
12 changes: 6 additions & 6 deletions src/js/template-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ var isCompatible = function(detailedException) {
var checkBadBrowserExtensions = function() {
var id = 'checkbadbrowsersframe';
var origTpl = ko.bindingHandlers.bindIframe.tpl;
ko.bindingHandlers.bindIframe.tpl = "<!DOCTYPE html>\r\n<html>\r\n<head><title>A</title>\r\n</head>\r\n<body><p style=\"color: blue\" align=\"right\" data-bind=\"style: { color: 'red' }\">B</p><div data-bind=\"text: content\"></div></body>\r\n</html>\r\n";
ko.bindingHandlers.bindIframe.tpl = "<!DOCTYPE html>\r\n<html>\r\n<head><title>A</title>\r\n</head>\r\n<body><p align=\"right\" data-bind=\"attr: { align: 'left' }\">B</p><div data-bind=\"text: content\"></div></body>\r\n</html>\r\n";
$('body').append('<iframe id="' + id + '" data-bind="bindIframe: $data"></iframe>');
var frameEl = global.document.getElementById(id);
ko.applyBindings({ content: "dummy content" }, frameEl);
Expand All @@ -398,11 +398,11 @@ var checkBadBrowserExtensions = function() {
ko.removeNode(frameEl);
ko.bindingHandlers.bindIframe.tpl = origTpl;

var expected = "<!DOCTYPE html>\n<html><head><title>A</title>\n</head>\n<body><p align=\"right\" style=\"color: red;\" data-bind=\"style: { color: 'red' }\">B</p><div data-bind=\"text: content\">dummy content</div>\n\n</body></html>";
var expected2 = "<!DOCTYPE html>\n<html><head><title>A</title>\n</head>\n<body><p style=\"color: red;\" data-bind=\"style: { color: 'red' }\" align=\"right\">B</p><div data-bind=\"text: content\">dummy content</div>\n\n</body></html>";
var expected3 = "<!DOCTYPE html>\n<html><head><title>A</title>\n</head>\n<body><p style=\"color: red;\" align=\"right\" data-bind=\"style: { color: 'red' }\">B</p><div data-bind=\"text: content\">dummy content</div>\n\n</body></html>";
if (expected !== content && expected2 !== content && expected3 !== content) {
console.info("BadBrowser.FrameContentCheck", content.length, expected.length, expected2.length, expected3.length, content == expected, content == expected2, content == expected3);
var expected = "<!DOCTYPE html>\n<html><head><title>A</title>\n</head>\n<body><p align=\"left\" data-bind=\"attr: { align: 'left' }\">B</p><div data-bind=\"text: content\">dummy content</div>\n\n</body></html>";
// Firefox changes the attributes order.
var expected2 = "<!DOCTYPE html>\n<html><head><title>A</title>\n</head>\n<body><p data-bind=\"attr: { align: 'left' }\" align=\"left\">B</p><div data-bind=\"text: content\">dummy content</div>\n\n</body></html>";
if (expected !== content && expected2 !== content) {
console.info("BadBrowser.FrameContentCheck", content.length, expected.length, expected2.length, content == expected, content == expected2);
console.warn("Detected incompatible/misbehaving browser, probably introduced by a bad browser extension.");
console.warn(content);
throw "Detected misbehaving browser/extension: unexpected frame content.";
Expand Down

0 comments on commit e8d6f60

Please sign in to comment.