Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

scrollingelement

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scrollingelement - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

2

package.json
{
"name": "scrollingelement",
"version": "1.1.0",
"version": "1.2.0",
"description": "A `document.scrollingElement` polyfill.",

@@ -5,0 +5,0 @@ "homepage": "https://mths.be/scrollingelement",

@@ -7,3 +7,3 @@ # `document.scrollingElement`

In your HTML document:
In an HTML document:

@@ -16,2 +16,14 @@ ```html

The polyfill can be used in `frameset` HTML documents (in that case, place the `<script>` in the `<head>`) or in XML documents as well.
## Browser support
The polyfill has been tested in the following browsers:
* Chrome
* Firefox 3.5+
* Internet Explorer 8+ (but [should work even in older versions](https://github.com/mathiasbynens/document.scrollingElement/issues/4))
* Opera 11.64+
* Safari 8+ (but [should work even in Safari 4](https://github.com/mathiasbynens/document.scrollingElement/issues/5))
## Acknowledgements

@@ -18,0 +30,0 @@

@@ -1,37 +0,50 @@

/*! https://mths.be/scrollingelement v1.1.0 by @diegoperini & @mathias | MIT license */
if (!('scrollingElement' in document)) {
(function() {
/*! https://mths.be/scrollingelement v1.2.0 by @diegoperini & @mathias | MIT license */
if (!('scrollingElement' in document)) (function() {
var html = document.documentElement;
var isCompliant = false;
var isStandardsMode = /^CSS1/.test(document.compatMode);
var html = document.documentElement;
var isCompliant = false;
var isStandardsMode = /^CSS1/.test(document.compatMode);
if (isStandardsMode) {
var iframe = document.createElement('iframe');
iframe.style.height = '1px';
(document.body || html).appendChild(iframe);
var doc = iframe.contentWindow.document;
doc.write('<!DOCTYPE html><div style="height:9999em">x</div>');
doc.close();
isCompliant = doc.documentElement.scrollHeight > doc.body.scrollHeight;
iframe.parentNode.removeChild(iframe);
if (isStandardsMode) {
var iframe = document.createElement('iframe');
iframe.style.height = '1px';
(document.body || html).appendChild(iframe);
var doc = iframe.contentWindow.document;
doc.write('<!DOCTYPE html><div style="height:9999em">x</div>');
doc.close();
isCompliant = doc.documentElement.scrollHeight > doc.body.scrollHeight;
iframe.parentNode.removeChild(iframe);
}
var scrollingElement = function() {
var body = document.body;
if (isCompliant) { // Note: this is `isStandardsMode && isCompliant`.
return html;
}
// Note: `document.body` could be a `frameset` element, or `null`.
// `tagName` is uppercase in HTML, but lowercase in XML.
var isFrameset = body && !/body/i.test(body.tagName);
return isFrameset ? null : body;
};
var scrollingElement = function() {
var body = document.body;
if (isStandardsMode && isCompliant) {
return html;
}
// Note: `document.body` could be a `frameset` element, or `null`.
// `tagName` is uppercase in HTML, but lowercase in XML.
var isFrameset = body && !/body/i.test(body.tagName);
return isFrameset ? null : body;
};
if ('defineProperty' in Object) {
// Support modern browsers that lack a native implementation.
Object.defineProperty(document, 'scrollingElement', {
'get': scrollingElement
});
} else if ('__defineGetter__' in document) {
// Support Firefox ≤ 3.6.9, Safari ≤ 4.1.3.
document.__defineGetter__('scrollingElement', scrollingElement);
} else if ('attachEvent' in document) {
// Support IE ≤ 7.
document.scrollingElement = scrollingElement();
document.attachEvent('onpropertychange', function() {
// A `propertychange` event fires when `<body>` is parsed because
// `document.activeElement` then changes.
if (window.event.propertyName == 'activeElement') {
document.scrollingElement = scrollingElement();
}
});
}
}());
}
}());
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc