Comparing version 0.4.44 to 0.4.45
@@ -5,8 +5,5 @@ import { PropType } from 'vue'; | ||
onResize: PropType<VResizeObserverOnResize>; | ||
}, { | ||
registered: boolean; | ||
handleResize(entry: ResizeObserverEntry): void; | ||
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{ | ||
}, void, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{ | ||
onResize: PropType<VResizeObserverOnResize>; | ||
}>>, {}>; | ||
export default _default; |
@@ -1,2 +0,2 @@ | ||
import { defineComponent, renderSlot } from 'vue'; | ||
import { defineComponent, renderSlot, getCurrentInstance, onMounted, onBeforeUnmount } from 'vue'; | ||
import delegate from './delegate'; | ||
@@ -10,33 +10,33 @@ import { warn } from '../../shared'; | ||
setup(props) { | ||
return { | ||
registered: false, | ||
handleResize(entry) { | ||
const { onResize } = props; | ||
if (onResize !== undefined) | ||
onResize(entry); | ||
} | ||
}; | ||
}, | ||
mounted() { | ||
const el = this.$el; | ||
if (el === undefined) { | ||
warn('resize-observer', '$el does not exist.'); | ||
return; | ||
let registered = false; | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const proxy = getCurrentInstance().proxy; | ||
function handleResize(entry) { | ||
const { onResize } = props; | ||
if (onResize !== undefined) | ||
onResize(entry); | ||
} | ||
if (el.nextElementSibling !== el.nextSibling) { | ||
if (el.nodeType === 3 && el.nodeValue !== '') { | ||
warn('resize-observer', '$el can not be observed (it may be a text node).'); | ||
onMounted(() => { | ||
const el = proxy.$el; | ||
if (el === undefined) { | ||
warn('resize-observer', '$el does not exist.'); | ||
return; | ||
} | ||
} | ||
if (el.nextElementSibling !== null) { | ||
delegate.registerHandler(el.nextElementSibling, this.handleResize); | ||
this.registered = true; | ||
} | ||
if (el.nextElementSibling !== el.nextSibling) { | ||
if (el.nodeType === 3 && el.nodeValue !== '') { | ||
warn('resize-observer', '$el can not be observed (it may be a text node).'); | ||
return; | ||
} | ||
} | ||
if (el.nextElementSibling !== null) { | ||
delegate.registerHandler(el.nextElementSibling, handleResize); | ||
registered = true; | ||
} | ||
}); | ||
onBeforeUnmount(() => { | ||
if (registered) { | ||
delegate.unregisterHandler(proxy.$el.nextElementSibling); | ||
} | ||
}); | ||
}, | ||
beforeUnmount() { | ||
if (this.registered) { | ||
delegate.unregisterHandler(this.$el.nextElementSibling); | ||
} | ||
}, | ||
render() { | ||
@@ -43,0 +43,0 @@ return renderSlot(this.$slots, 'default'); |
@@ -5,8 +5,5 @@ import { PropType } from 'vue'; | ||
onResize: PropType<VResizeObserverOnResize>; | ||
}, { | ||
registered: boolean; | ||
handleResize(entry: ResizeObserverEntry): void; | ||
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{ | ||
}, void, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{ | ||
onResize: PropType<VResizeObserverOnResize>; | ||
}>>, {}>; | ||
export default _default; |
@@ -15,33 +15,33 @@ "use strict"; | ||
setup(props) { | ||
return { | ||
registered: false, | ||
handleResize(entry) { | ||
const { onResize } = props; | ||
if (onResize !== undefined) | ||
onResize(entry); | ||
} | ||
}; | ||
}, | ||
mounted() { | ||
const el = this.$el; | ||
if (el === undefined) { | ||
(0, shared_1.warn)('resize-observer', '$el does not exist.'); | ||
return; | ||
let registered = false; | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const proxy = (0, vue_1.getCurrentInstance)().proxy; | ||
function handleResize(entry) { | ||
const { onResize } = props; | ||
if (onResize !== undefined) | ||
onResize(entry); | ||
} | ||
if (el.nextElementSibling !== el.nextSibling) { | ||
if (el.nodeType === 3 && el.nodeValue !== '') { | ||
(0, shared_1.warn)('resize-observer', '$el can not be observed (it may be a text node).'); | ||
(0, vue_1.onMounted)(() => { | ||
const el = proxy.$el; | ||
if (el === undefined) { | ||
(0, shared_1.warn)('resize-observer', '$el does not exist.'); | ||
return; | ||
} | ||
} | ||
if (el.nextElementSibling !== null) { | ||
delegate_1.default.registerHandler(el.nextElementSibling, this.handleResize); | ||
this.registered = true; | ||
} | ||
if (el.nextElementSibling !== el.nextSibling) { | ||
if (el.nodeType === 3 && el.nodeValue !== '') { | ||
(0, shared_1.warn)('resize-observer', '$el can not be observed (it may be a text node).'); | ||
return; | ||
} | ||
} | ||
if (el.nextElementSibling !== null) { | ||
delegate_1.default.registerHandler(el.nextElementSibling, handleResize); | ||
registered = true; | ||
} | ||
}); | ||
(0, vue_1.onBeforeUnmount)(() => { | ||
if (registered) { | ||
delegate_1.default.unregisterHandler(proxy.$el.nextElementSibling); | ||
} | ||
}); | ||
}, | ||
beforeUnmount() { | ||
if (this.registered) { | ||
delegate_1.default.unregisterHandler(this.$el.nextElementSibling); | ||
} | ||
}, | ||
render() { | ||
@@ -48,0 +48,0 @@ return (0, vue_1.renderSlot)(this.$slots, 'default'); |
{ | ||
"name": "vueuc", | ||
"version": "0.4.44", | ||
"version": "0.4.45", | ||
"description": "Util Components for Vue", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
224223
5810