Skip to content

Commit 63df897

Browse files
authored
fix: Add in missing polyfills for pfelement (#1625)
* fix: Add in missing polyfills for pfelement * fix: Update changelog * fix: Remove polyfill reference
1 parent f8be0e7 commit 63df897

File tree

8 files changed

+21
-122
lines changed

8 files changed

+21
-122
lines changed

CHANGELOG-1.x.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
- [f1c1176](https://github.com/patternfly/patternfly-elements/commit/f1c1176d9278d6e5b8066b42fc040ea01d98ecb2) feat: pfe-icon now supports setting default icon sets
44
- [267ff8e](https://github.com/patternfly/patternfly-elements/commit/267ff8ee7df7cd0512f16c58fdb169f941bfa4cd) feat: Update fetch mixin to support region input (#1328)
55
- [56eb55e](https://github.com/patternfly/patternfly-elements/commit/56eb55ec8b4b62aee7d36950d158229cbf50ddef) fix: pfe-accordion IE11 regression; background context should always be white with black text
6-
- [](https://github.com/patternfly/patternfly-elements/commit/) fix: [pfe-icon] Update icon color vs. background color custom property support
7-
6+
- [398003e](https://github.com/patternfly/patternfly-elements/commit/398003e3d805567af826d924bfd5e2e9655425a4) fix: [pfe-icon] Update icon color vs. background color custom property support
7+
- [](https://github.com/patternfly/patternfly-elements/commit/) fix: Add in missing polyfills for pfelement
88

99
# 1.7.0 (2021-05-10)
1010

elements/pfe-band/src/pfe-band.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// Import polyfills: matches, closest, includes
2-
import "./polyfills--pfe-band.js";
3-
41
import PFElement from "../../pfelement/dist/pfelement.js";
52

63
class PfeBand extends PFElement {

elements/pfe-band/src/polyfills--pfe-band.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

elements/pfe-card/src/pfe-card.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// Import polyfills: matches, closest, includes
2-
import "./polyfills--pfe-card.js";
3-
41
import PFElement from "../../pfelement/dist/pfelement.js";
52

63
class PfeCard extends PFElement {

elements/pfe-card/src/polyfills--pfe-card.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

elements/pfe-navigation/src/polyfills--pfe-navigation.js

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -39,78 +39,6 @@ if (!Array.prototype.filter) {
3939
};
4040
}
4141

42-
// @POLYFILL Element.prototype.matches
43-
// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
44-
if (!Element.prototype.matches) {
45-
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
46-
}
47-
48-
// @POLYFILL Element.prototype.closest
49-
// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
50-
if (!Element.prototype.closest) {
51-
Element.prototype.closest = function(s) {
52-
var el = this;
53-
54-
do {
55-
if (el.matches(s)) return el;
56-
el = el.parentElement || el.parentNode;
57-
} while (el !== null && el.nodeType === 1);
58-
return null;
59-
};
60-
}
61-
62-
// @POLYFILL Array.prototype.includes
63-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes
64-
if (!Array.prototype.includes) {
65-
Object.defineProperty(Array.prototype, "includes", {
66-
value: function(searchElement, fromIndex) {
67-
// 1. Let O be ? ToObject(this value).
68-
if (this == null) {
69-
throw new TypeError('"this" is null or not defined');
70-
}
71-
72-
var o = Object(this);
73-
74-
// 2. Let len be ? ToLength(? Get(O, "length")).
75-
var len = o.length >>> 0;
76-
77-
// 3. If len is 0, return false.
78-
if (len === 0) {
79-
return false;
80-
}
81-
82-
// 4. Let n be ? ToInteger(fromIndex).
83-
// (If fromIndex is undefined, this step produces the value 0.)
84-
var n = fromIndex | 0;
85-
86-
// 5. If n ≥ 0, then
87-
// a. Let k be n.
88-
// 6. Else n < 0,
89-
// a. Let k be len + n.
90-
// b. If k < 0, let k be 0.
91-
var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
92-
93-
function sameValueZero(x, y) {
94-
return x === y || (typeof x === "number" && typeof y === "number" && isNaN(x) && isNaN(y));
95-
}
96-
97-
// 7. Repeat, while k < len
98-
while (k < len) {
99-
// a. Let elementK be the result of ? Get(O, ! ToString(k)).
100-
// b. If SameValueZero(searchElement, elementK) is true, return true.
101-
// c. Increase k by 1.
102-
if (sameValueZero(o[k], searchElement)) {
103-
return true;
104-
}
105-
k++;
106-
}
107-
108-
// 8. Return false
109-
return false;
110-
}
111-
});
112-
}
113-
11442
// @POLYFILL Event.prototype.path
11543
// https://stackoverflow.com/questions/36845515/mouseevent-path-equivalent-in-firefox-safari
11644
if (!("path" in Event.prototype)) {

elements/pfe-tabs/src/polyfills--pfe-tabs.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,3 @@ if (!Array.prototype.findIndex) {
9393
writable: true
9494
});
9595
}
96-
97-
// @POLYFILL Element.prototype.matches
98-
// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill
99-
if (!Element.prototype.matches) {
100-
Element.prototype.matches = Element.prototype.msMatchesSelector;
101-
}

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,22 @@ if (!String.prototype.startsWith) {
7373
}
7474
});
7575
}
76+
77+
// @POLYFILL Element.closest
78+
// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
79+
if (!Element.prototype.closest) {
80+
Element.prototype.closest = function(s) {
81+
var el = this;
82+
do {
83+
if (el.matches(s)) return el;
84+
el = el.parentElement || el.parentNode;
85+
} while (el !== null && el.nodeType === 1);
86+
return null;
87+
};
88+
}
89+
90+
// @POLYFILL Element.matches
91+
// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
92+
if (!Element.prototype.matches) {
93+
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
94+
}

0 commit comments

Comments
 (0)