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 Aug 30, 2016
1 parent f7c12fd commit 6e625aa
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 @@ -99,7 +99,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 @@ -113,7 +113,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 @@ -155,8 +155,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 @@ -171,8 +171,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 @@ -233,8 +233,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 @@ -251,8 +251,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 6e625aa

Please sign in to comment.