Finished moving tag-manager from a vue to a component

Now tags load with the page, not via AJAX.
This commit is contained in:
Dan Brown
2020-06-29 22:11:03 +01:00
parent 4e107b9160
commit 573c4e26d5
21 changed files with 153 additions and 335 deletions

View File

@ -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') {