Skip to content

Commit

Permalink
Merge pull request #26 from Brightspace/dbatiste/polymer-2-fix-visibl…
Browse files Browse the repository at this point in the history
…e-on-ancestor

Wait a frame till after nodes are distributed before checking for vis…
  • Loading branch information
dbatiste authored Aug 16, 2018
2 parents 8f57a04 + 63cc51d commit 3c77b7a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion d2l-visible-on-ancestor-behavior.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@

__voaHandleVisibleOnAncestor: function(newValue, oldValue) {
if (newValue) {
this.__voaInit();
requestAnimationFrame(function() {
this.__voaInit();
}.bind(this));
} else if (oldValue) {
this.__voaUninit();
}
Expand Down
13 changes: 9 additions & 4 deletions test/visible-on-ancestor-behavior.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@
it('is not visible after adding visible-on-ancestor attribute', function(done) {
voaFixture.querySelector('#wc1').setAttribute('visible-on-ancestor', 'visible-on-ancestor');
requestAnimationFrame(function() {
expect(isDisplayed(voaFixture.querySelector('#wc1'))).to.equal(false);
done();
requestAnimationFrame(function() {
expect(isDisplayed(voaFixture.querySelector('#wc1'))).to.equal(false);
done();
});
});
});

Expand Down Expand Up @@ -122,8 +124,11 @@
expect(isDisplayed(voaFixture.querySelector('#wc2'))).to.equal(true);
});

it('is not visible if visible visible-on-ancestor attribute is specified', function() {
expect(isDisplayed(voaFixture.querySelector('#wc3'))).to.equal(false);
it('is not visible if visible visible-on-ancestor attribute is specified', function(done) {
requestAnimationFrame(function() {
expect(isDisplayed(voaFixture.querySelector('#wc3'))).to.equal(false);
done();
});
});

it('is visible if mouseenter event fires for visible-on-ancestor target', function(done) {
Expand Down

0 comments on commit 3c77b7a

Please sign in to comment.