Skip to content

Commit b717636

Browse files
authored
fix: pfelement - only resetContext on a nested child element during contextUpdate if resetContext is available on the child element (#1704)
* fix: wait for nested children to upgrade before calling resetContext on them Fixes #1703 * adding changelog update * removing isUpgraded property since its not used * the promise in contextUpdate for nested elements is no longer needed * updating changelog for pfelement fix * increasing diff ratio just a hair for pfe-dropdown
1 parent 7f9c30e commit b717636

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

CHANGELOG-1.x.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# 1.10.1 (2021)
22

3+
- [](https://github.com/patternfly/patternfly-elements/commit/) fix: pfelement - only resetContext on a nested child element during contextUpdate if resetContext is available on the child
34
- [fdc60ab](https://github.com/patternfly/patternfly-elements/commit/) fix: pfe-tabs issue with active border color on horizontal/wind (#1585)
45

56
# 1.10.0 (2021-07-08)
67

8+
- [c9c3b56](https://github.com/patternfly/patternfly-elements/commit/c9c3b5654ac05875eabfce0727c54af183e4ac09) chore: Minor testing updates
79
- [af4bc70](https://github.com/patternfly/patternfly-elements/commit/af4bc7063b995c316320f6df706b744133f1753d) feat: Jump links navigation rework to support panel customizations and elements in separate DOMs; horizontal designs aligned to kit
810

911

elements/pfe-dropdown/test/pfe-dropdown_e2e.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ describe(element, () => {
2424
});
2525

2626
it("should compare to the baseline", () => {
27-
expect(browser.checkFullPageScreen(element)).toBeLessThan(1.45);
27+
expect(browser.checkFullPageScreen(element)).toBeLessThan(1.52);
2828
});
2929
});

elements/pfelement/src/pfelement.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,12 @@ class PFElement extends HTMLElement {
328328

329329
// Loop over the nested elements and reset their context
330330
nestedEls.map((child) => {
331-
this.log(`Update context of ${child.tagName.toLowerCase()}`);
332-
Promise.all([customElements.whenDefined(child.tagName.toLowerCase())]).then(() => {
331+
if (child.resetContext) {
332+
this.log(`Update context of ${child.tagName.toLowerCase()}`);
333+
333334
// Ask the component to recheck it's context in case it changed
334335
child.resetContext(this.on);
335-
});
336+
}
336337
});
337338
}
338339

elements/pfelement/test/pfelement_test.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,19 @@
180180
// Class-thrown error
181181
assert.throws(() => PFElement.error("Hey!"), "Hey!");
182182
});
183+
184+
test("it should have a pfelement attribute after the component has been initialized", done => {
185+
const testElement = document.createElement("pfe-test-element");
186+
assert.isFalse(testElement.hasAttribute("pfelement"));
187+
188+
document.body.appendChild(testElement);
189+
190+
flush(() => {
191+
assert.isTrue(testElement.hasAttribute("pfelement"));
192+
document.body.removeChild(testElement);
193+
done();
194+
});
195+
});
183196
});
184197
</script>
185198

0 commit comments

Comments
 (0)