Current File : /home/exataengenharia/public_html/node_modules/alpinejs/src/magics/$id.js
import { magic } from '../magics'
import { closestIdRoot, findAndIncrementId } from '../ids'

magic('id', el => (name, key = null) => {
    let root = closestIdRoot(el, name)

    let id = root
        ? root._x_ids[name]
        : findAndIncrementId(name)

    return key
        ? `${name}-${id}-${key}`
        : `${name}-${id}`
})