vue-intersect
Advanced tools
Comparing version 1.1.4 to 1.1.5
@@ -168,4 +168,31 @@ import Vue from 'vue/dist/vue.js' | ||
expect(spy.disconnect).toHaveBeenCalledTimes(1) | ||
spy.disconnect.mockClear() | ||
}) | ||
test('It should emit event when component is destroyed', async () => { | ||
const mockedIntersect = Object.assign({}, Intersect) | ||
const onDestroy = jest.fn() | ||
const spy = { | ||
destroyed: jest.spyOn(mockedIntersect, 'destroyed'), | ||
disconnect: jest.spyOn(global.IntersectionObserver.prototype, 'disconnect') | ||
} | ||
const vm = new Vue({ | ||
template: `<intersect @destroyed="onDestroy"><div></div></intersect>`, | ||
components: {Intersect: mockedIntersect}, | ||
methods: { | ||
onDestroy | ||
} | ||
}).$mount() | ||
await vm.$nextTick() | ||
vm.$destroy() | ||
expect(spy.destroyed).toHaveBeenCalledTimes(1) | ||
expect(spy.disconnect).toHaveBeenCalledTimes(1) | ||
expect(onDestroy).toHaveBeenCalledTimes(1) | ||
}) | ||
test('It should warn when no child component is defined', async () => { | ||
@@ -172,0 +199,0 @@ global.console.warn = jest.fn() |
{ | ||
"name": "vue-intersect", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "A Vue component to add intersection-observer to a Vue component or HTML element.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -101,2 +101,3 @@ # Vue Intersect | ||
| **leave** | [*IntersectionObserverEntry*](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry) | Event fired when the element is *not* intersected (not visible on the screen) | | ||
| **destroyed** | None | Fired when the underlying element is destroyed | | ||
@@ -103,0 +104,0 @@ |
@@ -56,2 +56,3 @@ import Vue from 'vue' | ||
destroyed () { | ||
this.$emit('destroyed') | ||
this.observer.disconnect() | ||
@@ -58,0 +59,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
17975
332
118
0