Skip to content

Commit 5a8c9ee

Browse files
authored
fix: missing style tag b/c no html template loaded (#1503)
* fix: Add back an empty html file so the style tag can be appended * fix: Changelog update * fix: Add a container to maintain style tag in rebuild * fix: Add polyfill to fix IE11 break * fix: Update baselines
1 parent c634f59 commit 5a8c9ee

File tree

9 files changed

+31
-18
lines changed

9 files changed

+31
-18
lines changed

CHANGELOG-1.x.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# 1.4.0 (2021)
1+
# 1.4.0 (2021-03-30)
22

3-
- [](https://github.com/patternfly/patternfly-elements/commit/) feat: Add performance marks to PFElement for more accurate reporting on performance
3+
- [76c2c36](https://github.com/patternfly/patternfly-elements/commit/76c2c3689a9a338b278d99f6e2d3cbeef4f3cc3d) feat: Add performance marks to PFElement for more accurate reporting on performance
4+
- [](https://github.com/patternfly/patternfly-elements/commit/) fix: pfe-content-set bring back template to inject style tag for alignment settings
45

56
# 1.3.4 (2021-03-29)
67

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div id="container"></div>

elements/pfe-content-set/src/pfe-content-set.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ class PfeContentSet extends PFElement {
1919
return "pfe-content-set.scss";
2020
}
2121

22+
get templateUrl() {
23+
return "pfe-content-set.html";
24+
}
25+
2226
static get meta() {
2327
return {
2428
title: "Content set",
@@ -171,7 +175,7 @@ class PfeContentSet extends PFElement {
171175
get view() {
172176
if (!this._rendered) return;
173177

174-
return this.shadowRoot.querySelector(this.expectedTag);
178+
return this.shadowRoot.querySelector(`#container > ${this.expectedTag}`);
175179
}
176180

177181
/**
@@ -475,8 +479,8 @@ class PfeContentSet extends PFElement {
475479
// @todo find out why we need this shim
476480
// Shadydom breaks if we use innerHTML to set the new content but Selenium will infinitely
477481
// loop in out tests if we use appendChild.
478-
if (window.ShadyDOM) this.shadowRoot.appendChild(view);
479-
else this.shadowRoot.innerHTML = view.outerHTML;
482+
if (window.ShadyDOM) this.shadowRoot.querySelector(`#container`).appendChild(view);
483+
else this.shadowRoot.querySelector(`#container`).innerHTML = view.outerHTML;
480484

481485
Promise.all([customElements.whenDefined(tag)]).then(() => {
482486
this.cascadeProperties();

elements/pfe-content-set/test/pfe-content-set_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ suite("<pfe-content-set> cascading attributes", () => {
318318
pfeContentSet.setAttribute("vertical", "");
319319

320320
flush(() => {
321-
const pfeTabs = pfeContentSet.shadowRoot.querySelector(':scope > pfe-tabs');
321+
const pfeTabs = pfeContentSet.shadowRoot.querySelector('pfe-tabs');
322322
assert.equal(pfeContentSet.getAttribute("vertical"), pfeTabs.getAttribute("vertical"));
323323

324324
done();

elements/pfelement/src/pfelement.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ class PFElement extends HTMLElement {
308308
} else if (this.id.startsWith("pfe-") && !this.id.startsWith(this.tag)) {
309309
this._markId = this.id.replace("pfe", this.tag);
310310
} else {
311-
this._markId = `${this.tag}-${this.id}`;
311+
this._markId = `${this.tag}-${this.id}`;
312312
}
313313

314314
this._markCount = 0;
@@ -421,16 +421,12 @@ class PFElement extends HTMLElement {
421421
if (PFElement.trackPerformance()) {
422422
try {
423423
performance.mark(`${this._markId}-rendered`);
424-
424+
425425
if (this._markCount < 1) {
426426
this._markCount = this._markCount + 1;
427427

428428
// Navigation start, i.e., the browser first sees that the user has navigated to the page
429-
performance.measure(
430-
`${this._markId}-from-navigation-to-first-render`,
431-
undefined,
432-
`${this._markId}-rendered`
433-
);
429+
performance.measure(`${this._markId}-from-navigation-to-first-render`, undefined, `${this._markId}-rendered`);
434430

435431
// Render is run before connection unless delayRender is used
436432
performance.measure(

elements/pfelement/src/polyfills--pfelement.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,14 @@ if (!Object.entries) {
6262
return resArray;
6363
};
6464
}
65+
66+
// @POLYFILL String.startsWith
67+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith#polyfill
68+
if (!String.prototype.startsWith) {
69+
Object.defineProperty(String.prototype, "startsWith", {
70+
value: function(search, rawPos) {
71+
var pos = rawPos > 0 ? rawPos | 0 : 0;
72+
return this.substring(pos, pos + search.length) === search;
73+
}
74+
});
75+
}

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
-8.58 KB
Loading
832 Bytes
Loading

0 commit comments

Comments
 (0)