Skip to content

Commit

Permalink
fix: flush to make textContent work with ShadyDOM (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
shadikhani authored and web-padawan committed Jan 8, 2020
1 parent a992292 commit 9b0c1ac
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/vaadin-button.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@
this.$.button.setAttribute('role', 'presentation');

this._addActiveListeners();

// Fix for https://github.com/vaadin/vaadin-button-flow/issues/120
window.ShadyDOM && window.ShadyDOM.flush();
}

/**
Expand Down
38 changes: 38 additions & 0 deletions test/button-in-template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!doctype html>
<head>
<meta charset="UTF-8">
<title>vaadin-button tests</title>
<script src="../../web-component-tester/browser.js"></script>
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../../test-fixture/test-fixture.html">
<link rel="import" href="../vaadin-button.html">
</head>
<body>
<test-fixture id="wrapped-button">
<template>
<button-test></button-test>
</template>
</test-fixture>
<script>
customElements.whenDefined('vaadin-button').then(() => {
class ButtonTest extends Polymer.Element {
static get template() {
return Polymer.html`
<vaadin-button id="button">Old text</vaadin-button>
`;
}
ready() {
super.ready();
this.$.button.textContent = 'New text';
}
}
customElements.define('button-test', ButtonTest);
});
describe('vaadin-button in template', () => {
it('should flush in ready callback and update inner text', () => {
const wrapper = fixture('wrapped-button');
expect(wrapper.$.button.innerText.trim()).to.equal('New text');
});
});
</script>
</body>
3 changes: 2 additions & 1 deletion test/test-suites.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
window.VaadinButtonSuites = [
'vaadin-button_test.html'
'vaadin-button_test.html',
'button-in-template.html'
];

0 comments on commit 9b0c1ac

Please sign in to comment.