From 1b892e5739a9052d66e2e4451217dde88d7bd2ba Mon Sep 17 00:00:00 2001 From: Juan Valencia Calvellido Date: Tue, 18 Feb 2020 17:57:46 +0100 Subject: [PATCH 1/5] Update version and tags --- package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c16ebf1..285aed3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "focus-options-polyfill", - "version": "1.3.0", + "version": "1.4.0", "description": "JavaScript polyfill for the WHATWG spec of focusOptions, that enables a set of options to be passed to the focus method.", "main": "index.js", "scripts": { @@ -16,6 +16,9 @@ "polyfill", "javascript-polyfill", "focus", + "options", + "focusOptions", + "preventScroll", "whatwg", "whatwg-dom", "js" From a25360292e76b4bc448b0943efb8ff638c9c7817 Mon Sep 17 00:00:00 2001 From: Juan Valencia Calvellido Date: Tue, 18 Feb 2020 18:05:44 +0100 Subject: [PATCH 2/5] Use basic fallback for document.scrollingElement --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 9647bec..c1bb63e 100644 --- a/index.js +++ b/index.js @@ -37,8 +37,10 @@ var calcScrollableElements = function(element) { var parent = element.parentNode; var scrollableElements = []; + var rootScrollingElement = + document.scrollingElement || document.documentElement; - while (parent && parent !== document.scrollingElement) { + while (parent && parent !== rootScrollingElement) { if ( parent.offsetHeight < parent.scrollHeight || parent.offsetWidth < parent.scrollWidth @@ -51,7 +53,7 @@ } parent = parent.parentNode; } - parent = document.scrollingElement; + parent = rootScrollingElement; scrollableElements.push([parent, parent.scrollTop, parent.scrollLeft]); return scrollableElements; From 4b2f0e59ae247e22e00dfe5f769d2ae01c3bf65f Mon Sep 17 00:00:00 2001 From: Juan Valencia Calvellido Date: Tue, 18 Feb 2020 18:10:45 +0100 Subject: [PATCH 3/5] Update README.md --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index f836577..7ba2d8a 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,28 @@ https://caniuse.com/#feat=mdn-api_htmlelement_focus_preventscroll_option https://bugs.webkit.org/show_bug.cgi?id=178583 +## document.scrollingElement + +This polyfill uses a basic fallback for the [document.scrollingElement](https://developer.mozilla.org/en-US/docs/Web/API/Document/scrollingElement) property, using `document.documentElement` when not found. + +This could suffice in basic cases, but if you need wider and/or specific support you should refer to a polyfill for it: + +* https://github.com/mathiasbynens/document.scrollingElement +* + +Also, to overcome its absence if you are executing this polyfill through [`jsdom`](https://github.com/jsdom/jsdom), you should place this in your setup: + +```js +document.scrollingElement = document.documentElement +``` + +More context about this property can be found in: + +* https://developer.mozilla.org/en-US/docs/Web/API/Document/scrollingElement +* https://developer.mozilla.org/en-US/docs/Web/HTML/Quirks_Mode_and_Standards_Mode +* https://developer.mozilla.org/en-US/docs/Web/API/Document/documentElement + + ## Dev and testing To check this polyfill you can do: From b495b182a1652a21d1779e7a4f5eb5ebd05d9e2b Mon Sep 17 00:00:00 2001 From: Juan Valencia Calvellido Date: Tue, 18 Feb 2020 18:12:07 +0100 Subject: [PATCH 4/5] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 7ba2d8a..6711e08 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,6 @@ This polyfill uses a basic fallback for the [document.scrollingElement](https:// This could suffice in basic cases, but if you need wider and/or specific support you should refer to a polyfill for it: * https://github.com/mathiasbynens/document.scrollingElement -* Also, to overcome its absence if you are executing this polyfill through [`jsdom`](https://github.com/jsdom/jsdom), you should place this in your setup: From c8a3b937dd508a2fca37fe1425a76ccbf1e93443 Mon Sep 17 00:00:00 2001 From: Juan Valencia Calvellido Date: Tue, 18 Feb 2020 18:20:33 +0100 Subject: [PATCH 5/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6711e08..98f9665 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ This could suffice in basic cases, but if you need wider and/or specific support * https://github.com/mathiasbynens/document.scrollingElement -Also, to overcome its absence if you are executing this polyfill through [`jsdom`](https://github.com/jsdom/jsdom), you should place this in your setup: +Also, to overcome its absence if you are executing this polyfill through [`jsdom`](https://github.com/jsdom/jsdom), you could place this in your setup: ```js document.scrollingElement = document.documentElement