Skip to content

Commit

Permalink
use promises to wait mutation observers
Browse files Browse the repository at this point in the history
  • Loading branch information
valdrinkoshi committed Nov 23, 2016
1 parent 751c6ec commit 36f3755
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('Basic', function() {
newButton.textContent = 'Click me too';
const inertContainer = document.querySelector('[inert]');
inertContainer.appendChild(newButton);
// Wait for the next microtask to allow mutation observers to react to the DOM change
// Wait for the next microtask to allow mutation observers to react to the DOM change.
Promise.resolve().then(() => {
expect(isUnfocusable(newButton)).to.equal(true);
done();
Expand All @@ -115,7 +115,7 @@ describe('Basic', function() {
expect(temp.parentElement).to.eql(fixture);
temp.outerHTML = '<div id="inert2" inert><button>Click me</button></div>';
const div = fixture.querySelector('#inert2');
// Wait for the next microtask to allow mutation observers to react to the DOM change
// Wait for the next microtask to allow mutation observers to react to the DOM change.
Promise.resolve().then(() => {
expect(div.inert).to.equal(true);
const button = div.querySelector('button');
Expand Down Expand Up @@ -157,8 +157,8 @@ describe('Basic', function() {
const shadowButton = document.createElement('button');
shadowButton.textContent = 'Shadow button';
host.shadowRoot.appendChild(shadowButton);
// Give time to mutation observers.
setTimeout(function() {
// Wait for the next microtask to allow mutation observers to react to the DOM change.
Promise.resolve().then(() => {
expect(isUnfocusable(shadowButton)).to.equal(true);
done();
});
Expand All @@ -173,8 +173,8 @@ describe('Basic', function() {
const shadowButton = document.createElement('button');
shadowButton.textContent = 'Shadow button';
shadowRoot.appendChild(shadowButton);
// Give time to mutation observers.
setTimeout(function() {
// Wait for the next microtask to allow mutation observers to react to the DOM change.
Promise.resolve().then(() => {
expect(isUnfocusable(shadowButton)).to.equal(true);
done();
});
Expand Down Expand Up @@ -235,8 +235,8 @@ describe('Basic', function() {
const shadowButton = document.createElement('button');
shadowButton.textContent = 'Shadow button';
host.shadowRoot.appendChild(shadowButton);
// Give time to mutation observers.
setTimeout(function() {
// Wait for the next microtask to allow mutation observers to react to the DOM change.
Promise.resolve().then(() => {
expect(isUnfocusable(shadowButton)).to.equal(true);
done();
});
Expand All @@ -253,8 +253,8 @@ describe('Basic', function() {
const shadowButton = document.createElement('button');
shadowButton.textContent = 'Shadow button';
shadowRoot.appendChild(shadowButton);
// Give time to mutation observers.
setTimeout(function() {
// Wait for the next microtask to allow mutation observers to react to the DOM change.
Promise.resolve().then(() => {
expect(isUnfocusable(shadowButton)).to.equal(true);
done();
});
Expand Down

0 comments on commit 36f3755

Please sign in to comment.