Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update vendor polyfills to match upstream #1745

Merged
merged 3 commits into from
Feb 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we think this is useful for users to have this in the release notes, as it's mostly an internal change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I err on the side of strict most of the time, we'd probably get away with not having an entry though. Up to you.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no particular preference, was just unsure about it myself. Maybe @m-green can look at this when we come to cut the next release.

- [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 || {});