Skip to content

Commit

Permalink
Merge pull request #1745 from alphagov/update-vendor-polyfills-to-mat…
Browse files Browse the repository at this point in the history
…ch-upstream

Update vendor polyfills to match upstream
  • Loading branch information
NickColley authored Feb 25, 2020
2 parents 235a4c0 + a4072f2 commit 59218a0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 31 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

### Fixes

- [Pull request #1745: Update vendor polyfills to match upstream](https://github.com/alphagov/govuk-frontend/pull/1745).
- [Pull request #1724: Fix fallback logo being detected by Google Chrome's image description feature](https://github.com/alphagov/govuk-frontend/pull/1724).

## 3.5.0 (Feature release)
Expand Down
2 changes: 1 addition & 1 deletion src/govuk/vendor/polyfills/Element/prototype/closest.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import './matches'

if (detect) return

// Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/closest/polyfill.js
// Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/closest/polyfill.js
Element.prototype.closest = function closest(selector) {
var node = this;

Expand Down
26 changes: 10 additions & 16 deletions src/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,20 @@ import '../../Element'

(function(undefined) {

// Detection from https://github.com/Financial-Times/polyfill-service/pull/1062/files#diff-b09a5d2acf3314b46a6c8f8d0c31b85c
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-library/master/polyfills/Element/prototype/nextElementSibling/detect.js
var detect = (
'Element' in this && "nextElementSibling" in document.documentElement
'document' in this && "nextElementSibling" in document.documentElement
)

if (detect) return


(function (global) {

// There is no polyfill in polyfill-library (https://github.com/Financial-Times/polyfill-library/issues/338)
// So we source this from https://github.com/Alhadis/Snippets/blob/e09b4dfb7ffc9e250bc28319051e39ead3e5f70a/js/polyfills/IE8-child-elements.js#L28-L33
Object.defineProperty(Element.prototype, "nextElementSibling", {
get: function(){
var el = this.nextSibling;
while (el && el.nodeType !== 1) { el = el.nextSibling; }
return el;
}
});

}(this));
// Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-library/master/polyfills/Element/prototype/nextElementSibling/polyfill.js
Object.defineProperty(Element.prototype, "nextElementSibling", {
get: function(){
var el = this.nextSibling;
while (el && el.nodeType !== 1) { el = el.nextSibling; }
return el;
}
});

}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,20 @@ import '../../Element'

(function(undefined) {

// Detection from https://github.com/Financial-Times/polyfill-service/pull/1062/files#diff-a162235fbc9c0dd40d4032265f44942e
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-library/master/polyfills/Element/prototype/previousElementSibling/detect.js
var detect = (
'Element' in this && 'previousElementSibling' in document.documentElement
'document' in this && "previousElementSibling" in document.documentElement
)

if (detect) return

(function (global) {
// There is no polyfill in polyfill-library (https://github.com/Financial-Times/polyfill-library/issues/338)
// So we source this from https://github.com/Alhadis/Snippets/blob/e09b4dfb7ffc9e250bc28319051e39ead3e5f70a/js/polyfills/IE8-child-elements.js#L35-L40
Object.defineProperty(Element.prototype, 'previousElementSibling', {
get: function(){
var el = this.previousSibling;
while (el && el.nodeType !== 1) { el = el.previousSibling; }
return el;
}
});

}(this));
// Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-library/master/polyfills/Element/prototype/previousElementSibling/polyfill.js
Object.defineProperty(Element.prototype, 'previousElementSibling', {
get: function(){
var el = this.previousSibling;
while (el && el.nodeType !== 1) { el = el.previousSibling; }
return el;
}
});

}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});

0 comments on commit 59218a0

Please sign in to comment.