const map = new WeakMap()
const ob = new ResizeObserver(entries => {
    for (const entry of entries) {
        const handler = map.get(entry.target)
        if (handler) {
            const { inlineSize, blockSize } = entry.contentBoxSize[0]
            handler({ width: inlineSize, height: blockSize })
        }
    }
})
export default {
    bind(el, binding) {
        map.set(el, binding.value)
        ob.observe(el)
    },
    unbind(el) {
        ob.unobserve(el)
    }
}