Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
workaround for #44, add a dummy MutationObserver in IE 11
Browse files Browse the repository at this point in the history
Note: I'm not seeing this failure in IE 10, so it appears to not need any workaround code

[email protected]

Review URL: https://codereview.appspot.com/124460044
  • Loading branch information
John Messerly committed Aug 18, 2014
1 parent 96e952b commit 2f1242a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

suite('PolymerExpressions', function() {

var testDiv, originalConsoleError, errors;
var testDiv, originalConsoleError, errors, ieDummyObserver;


var getExpression = PolymerExpressions.getExpression;
Expand All @@ -27,13 +27,25 @@ suite('PolymerExpressions', function() {
errors.push(Array.prototype.slice.call(arguments));
};
testDiv = document.body.appendChild(document.createElement('div'));

// This is a workaround for a rare IE bug affecting identity of JS wrappers
// of Text nodes in the DOM. A dummy MutationObserver prevents the problem.
// https://github.com/Polymer/polymer-expressions/issues/44
if (/Trident/.test(navigator.userAgent) &&
typeof MutationObserver == 'function') {

ieDummyObserver = new MutationObserver(function() {});
ieDummyObserver.observe(testDiv, { childList: true, subtree: true });
}

Observer._errorThrownDuringCallback = false;
});

teardown(function() {
errors = [];
console.error = originalConsoleError;
assert.isFalse(!!Observer._errorThrownDuringCallback);
if (ieDummyObserver) ieDummyObserver.disconnect();
document.body.removeChild(testDiv);
clearAllTemplates(testDiv);
Platform.performMicrotaskCheckpoint();
Expand Down

0 comments on commit 2f1242a

Please sign in to comment.