New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

intersection-observer

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

intersection-observer - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

51

intersection-observer-test.js

@@ -612,14 +612,18 @@ /**

it('handles root/target elements not yet in the DOM', function(done) {
rootEl.parentNode.removeChild(rootEl);
targetEl1.parentNode.removeChild(targetEl1);
it('handles target elements not yet added to the DOM', function(done) {
var spy = sinon.spy();
io = new IntersectionObserver(spy, {root: rootEl});
// targetEl5 is initially not in the DOM. Note that this element must be
// created outside of the addFixtures() function to catch the IE11 error
// described here: https://github.com/WICG/IntersectionObserver/pull/205
var targetEl5 = document.createElement('div');
targetEl5.setAttribute('id', 'target5');
runSequence([
function(done) {
io.observe(targetEl1);
io.observe(targetEl5);
setTimeout(function() {
// Initial observe should trigger with no intersections since
// targetEl5 is not yet in the DOM.
expect(spy.callCount).to.be(1);

@@ -630,3 +634,3 @@ var records = sortRecords(spy.lastCall.args[0]);

expect(records[0].intersectionRatio).to.be(0);
expect(records[0].target).to.be(targetEl1);
expect(records[0].target).to.be(targetEl5);
done();

@@ -636,19 +640,10 @@ }, ASYNC_TIMEOUT);

function(done) {
// Adding rootEl without targetEl1 in it should trigger nothing.
document.getElementById('fixtures').appendChild(rootEl);
// Adding targetEl5 inside rootEl should trigger.
parentEl.insertBefore(targetEl5, targetEl2);
setTimeout(function() {
expect(spy.callCount).to.be(1);
done();
}, ASYNC_TIMEOUT);
},
function(done) {
// Adding targetEl1 inside rootEl should trigger.
parentEl.insertBefore(targetEl1, targetEl2);
setTimeout(function() {
expect(spy.callCount).to.be(2);
var records = sortRecords(spy.lastCall.args[0]);
expect(records.length).to.be(1);
expect(records[0].isIntersecting).to.be(true);
expect(records[0].intersectionRatio).to.be(1);
expect(records[0].target).to.be(targetEl1);
expect(records[0].target).to.be(targetEl5);
done();

@@ -658,3 +653,3 @@ }, ASYNC_TIMEOUT);

function(done) {
// Removing an ancestor of targetEl1 should trigger.
// Removing an ancestor of targetEl5 should trigger.
grandParentEl.parentNode.removeChild(grandParentEl);

@@ -665,5 +660,4 @@ setTimeout(function() {

expect(records.length).to.be(1);
expect(records[0].isIntersecting).to.be(false);
expect(records[0].intersectionRatio).to.be(0);
expect(records[0].target).to.be(targetEl1);
expect(records[0].target).to.be(targetEl5);
done();

@@ -673,5 +667,5 @@ }, ASYNC_TIMEOUT);

function(done) {
// Adding the previously removed targetEl1 (via grandParentEl) back
// directly inside rootEl should trigger.
rootEl.appendChild(targetEl1);
// Adding the previously removed targetEl5 (via grandParentEl)
// back directly inside rootEl should trigger.
rootEl.appendChild(targetEl5);
setTimeout(function() {

@@ -681,5 +675,4 @@ expect(spy.callCount).to.be(4);

expect(records.length).to.be(1);
expect(records[0].isIntersecting).to.be(true);
expect(records[0].intersectionRatio).to.be(1);
expect(records[0].target).to.be(targetEl1);
expect(records[0].target).to.be(targetEl5);
done();

@@ -696,3 +689,3 @@ }, ASYNC_TIMEOUT);

expect(records[0].intersectionRatio).to.be(0);
expect(records[0].target).to.be(targetEl1);
expect(records[0].target).to.be(targetEl5);
done();

@@ -993,3 +986,3 @@ }, ASYNC_TIMEOUT);

'}' +
'#target1, #target2, #target3, #target4 {' +
'#target1, #target2, #target3, #target4, #target5 {' +
' position: absolute;' +

@@ -996,0 +989,0 @@ ' top: 0px;' +

@@ -626,5 +626,12 @@ /**

function getBoundingClientRect(el) {
var rect = el.getBoundingClientRect();
if (!rect) return;
var rect;
try {
rect = el.getBoundingClientRect();
} catch (e) {/* ignore Windows 7 IE11 "Unspecified error" */}
if (!rect) {
return getEmptyRect();
}
// Older IE

@@ -631,0 +638,0 @@ if (!rect.width || !rect.height) {

{
"name": "intersection-observer",
"version": "0.3.0",
"version": "0.3.1",
"description": "A polyfill for IntersectionObserver",

@@ -5,0 +5,0 @@ "main": "intersection-observer",

@@ -88,10 +88,8 @@ # `IntersectionObserver` polyfill

Legacy support is also possible in very old browsers by including a shim for ES5 as well as the `window.getComputedStyle` method. The easiest way to support those browsers is via the following script from the [polyfill.io](https://cdn.polyfill.io/v2/docs/):
Legacy support is also possible in very old browsers by including a shim for ES5 as well as the `window.getComputedStyle` method. The easiest way to load the IntersectionObserver polyfill and have it work in the widest range of browsers is via [polyfill.io](https://cdn.polyfill.io/v2/docs/), which will automatically include dependencies where necessary:
```html
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=es5,getComputedStyle"></script>
<script src="https://polyfill.io/v2/polyfill.min.js?features=IntersectionObserver"></script>
```
**Note:** future versions of polyfill.io will include this `IntersectionObserver` polyfill, so the above code will no longer be necessary.
With these polyfills, `IntersectionObserver` has been tested an known to work in the following browsers:

@@ -102,33 +100,29 @@

<td align="center">
<img src="https://raw.github.com/alrra/browser-logos/master/chrome/chrome_48x48.png" alt="Chrome"><br>
<img src="https://raw.github.com/alrra/browser-logos/39.2.2/src/chrome/chrome_48x48.png" alt="Chrome"><br>
</td>
<td align="center">
<img src="https://raw.github.com/alrra/browser-logos/master/firefox/firefox_48x48.png" alt="Firefox"><br>
<img src="https://raw.github.com/alrra/browser-logos/39.2.2/src/firefox/firefox_48x48.png" alt="Firefox"><br>
</td>
<td align="center">
<img src="https://raw.github.com/alrra/browser-logos/master/safari/safari_48x48.png" alt="Safari"><br>
<img src="https://raw.github.com/alrra/browser-logos/39.2.2/src/safari/safari_48x48.png" alt="Safari"><br>
6+
</td>
<td align="center">
<img src="https://raw.github.com/alrra/browser-logos/master/edge/edge_48x48.png" alt="Edge"><br>
<img src="https://raw.github.com/alrra/browser-logos/39.2.2/src/edge/edge_48x48.png" alt="Edge"><br>
</td>
<td align="center">
<img src="https://raw.github.com/alrra/browser-logos/master/internet-explorer/internet-explorer_48x48.png" alt="Internet Explorer"><br>
<img src="https://raw.github.com/alrra/browser-logos/39.2.2/src/archive/internet-explorer_7-8/internet-explorer_7-8_48x48.png" alt="Internet Explorer"><br>
7+
</td>
<td align="center">
<img src="https://raw.github.com/alrra/browser-logos/master/opera/opera_48x48.png" alt="Opera"><br>
<img src="https://raw.github.com/alrra/browser-logos/39.2.2/src/opera/opera_48x48.png" alt="Opera"><br>
</td>
<td align="center">
<img src="https://raw.github.com/alrra/browser-logos/master/android/android_48x48.png" alt="Android"><br>
<img src="https://raw.github.com/alrra/browser-logos/39.2.2/src/android/android_48x48.png" alt="Android"><br>
4.4+
</td>
<td align="center">
<img src="https://raw.github.com/alrra/browser-logos/master/safari-ios/safari-ios_48x48.png" alt="iOS"><br>
9.2+
</td>
</tr>

@@ -135,0 +129,0 @@ </table>

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