import htmlTags from '../json/html-tags.json' with { type: 'json' }; import htmlVoidTags from '../json/html-tags-void.json' with { type: 'json' }; const browser = bowser.getParser(window.navigator.userAgent).getBrowser(); export let unifiedTagCollection = []; if (browser === "Chrome") { unifiedTagCollection = [...htmlTags, ...htmlVoidTags]; } else if (browser === "Firefox") { const htmlTags = await fetchMultipleJsonUrls([ `${window.location.origin}/json/html-tags.json`, `${window.location.origin}/json/html-tags-void.json` ]); unifiedTagCollection = [...htmlTags]; } else { unifiedTagCollection = [...htmlTags, ...htmlVoidTags]; } export default function isValidTag(tag) { return unifiedTagCollection.includes(tag); } /** @returns {Promise} */ async function fetchMultipleJsonUrls(urls) { const responses = await Promise.all(urls.map(url => fetch(url))); const jsonArrays = await Promise.all(responses.map(response => response.json())); return jsonArrays.flat(); }