X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/a5fa74574919a491986f197d41a5f8186a45562f..refs/pull/2169/head:/resources/js/components/index.js diff --git a/resources/js/components/index.js b/resources/js/components/index.js index 1cea8949e..68f97b280 100644 --- a/resources/js/components/index.js +++ b/resources/js/components/index.js @@ -70,13 +70,20 @@ function initComponent(name, element) { function parseRefs(name, element) { const refs = {}; const manyRefs = {}; + const prefix = `${name}@` - const refElems = element.querySelectorAll(`[refs*="${prefix}"]`); + const selector = `[refs*="${prefix}"]`; + const refElems = [...element.querySelectorAll(selector)]; + if (element.matches(selector)) { + refElems.push(element); + } + for (const el of refElems) { const refNames = el.getAttribute('refs') .split(' ') .filter(str => str.startsWith(prefix)) - .map(str => str.replace(prefix, '')); + .map(str => str.replace(prefix, '')) + .map(kebabToCamel); for (const ref of refNames) { refs[ref] = el; if (typeof manyRefs[ref] === 'undefined') {