import { HTMLTagAttributes, HTMLValue } from '../';
import { html5 } from './states';
/* -------------------------------------------- */
/* LOCAL SCOPES */
/* -------------------------------------------- */
/**
* Attribute Specification
*/
let attrs: string[];
/**
* Value Set Specification
*/
let values: HTMLValue[];
/**
* The current active attributes
*/
const unique: Set = new Set();
/* -------------------------------------------- */
/* SETTERS */
/* -------------------------------------------- */
/**
* Set Tag
*
* Finds a HTML tag and updates the scope reference to it.
* If no tag is found in the spec, it's likely a custom
* HTML tag, this is allowed but that is handled at the
* scanner/parser level.
*
* When a tag is matched, we immeadiatly check if the tag
* accepts a list of pre-defined attributes, if they exists
* we create a key list of the accepted values which we will
* use to match attributes.
*/
export function setHTMLTag (name: string): boolean {
html5.tag = undefined;
attrs = undefined;
unique.clear();
if (!html5.data.variation.tags?.[name]) return false;
html5.tag = html5.data.variation.tags[name];
if (html5.tag.attributes.length) {
attrs = html5.tag.attributes.map((attr: HTMLTagAttributes) => attr.name);
}
return true;
}
/* -------------------------------------------- */
/* VALIDATORS */
/* -------------------------------------------- */
/**
* Checks to see if the provided HTML tag is an
* embedded type tag, eg: