All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.dist.prod.util.getSingletonElementInstance.js.map Maven / Gradle / Ivy

{
  "version": 3,
  "sources": ["../../../src/util/getSingletonElementInstance.ts"],
  "sourcesContent": ["/**\n * Returns a singleton HTML element, inserted in given parent element of HTML page,\n * used mostly to store and share global resources between multiple UI5 Web Components runtimes.\n *\n * @param { string } tag the element tag/selector\n * @param { HTMLElement } parentElement the parent element to insert the singleton element instance\n * @param { Function } createEl a factory function for the element instantiation, by default document.createElement is used\n * @returns { Element }\n */\nconst getSingletonElementInstance = (tag: string, parentElement: HTMLElement = document.body, createEl?: () => Element) => {\n\tlet el = document.querySelector(tag);\n\n\tif (el) {\n\t\treturn el;\n\t}\n\n\tel = createEl ? createEl() : document.createElement(tag);\n\n\treturn parentElement.insertBefore(el, parentElement.firstChild);\n};\n\nexport default getSingletonElementInstance;\n"],
  "mappings": "aASA,MAAMA,EAA8B,CAACC,EAAaC,EAA6B,SAAS,KAAMC,IAA6B,CAC1H,IAAIC,EAAK,SAAS,cAAcH,CAAG,EAEnC,OAAIG,IAIJA,EAAKD,EAAWA,EAAS,EAAI,SAAS,cAAcF,CAAG,EAEhDC,EAAc,aAAaE,EAAIF,EAAc,UAAU,EAC/D,EAEA,eAAeF",
  "names": ["getSingletonElementInstance", "tag", "parentElement", "createEl", "el"]
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy