(elt, target)
| 2780 | delete elt._hyperscript; |
| 2781 | } |
| 2782 | #initElement(elt, target) { |
| 2783 | if (elt.closest && elt.closest(config.disableSelector)) { |
| 2784 | return; |
| 2785 | } |
| 2786 | var internalData = this.getInternalData(elt); |
| 2787 | var src = this.#getScript(elt); |
| 2788 | if (!src) return; |
| 2789 | var hash = this.#hashScript(src); |
| 2790 | if (internalData.initialized) { |
| 2791 | if (internalData.scriptHash === hash) { |
| 2792 | this.#resolveTemplateScopes(elt); |
| 2793 | return; |
| 2794 | } |
| 2795 | this.cleanup(elt); |
| 2796 | internalData = this.getInternalData(elt); |
| 2797 | } |
| 2798 | if (!this.triggerEvent(elt, "hyperscript:before:init")) return; |
| 2799 | internalData.initialized = true; |
| 2800 | internalData.scriptHash = hash; |
| 2801 | try { |
| 2802 | var tokens = this.#tokenizer.tokenize(src); |
| 2803 | var hyperScript = this.#kernel.parseHyperScript(tokens); |
| 2804 | if (!hyperScript) return; |
| 2805 | if (hyperScript.errors?.length) { |
| 2806 | this.triggerEvent(elt, "hyperscript:parse-error", { |
| 2807 | errors: hyperScript.errors |
| 2808 | }); |
| 2809 | console.error( |
| 2810 | "hyperscript: " + hyperScript.errors.length + " parse error(s) on:", |
| 2811 | elt, |
| 2812 | "\n\n" + Parser.formatErrors(hyperScript.errors) |
| 2813 | ); |
| 2814 | return; |
| 2815 | } |
| 2816 | this.#resolveTemplateScopes(elt); |
| 2817 | hyperScript.apply(target || elt, elt, null, this); |
| 2818 | elt.setAttribute("data-hyperscript-powered", "true"); |
| 2819 | this.triggerEvent(elt, "hyperscript:after:init"); |
| 2820 | setTimeout(() => { |
| 2821 | this.triggerEvent(target || elt, "load", { |
| 2822 | hyperscript: true |
| 2823 | }); |
| 2824 | }, 1); |
| 2825 | } catch (e) { |
| 2826 | this.triggerEvent(elt, "exception", { |
| 2827 | error: e |
| 2828 | }); |
| 2829 | console.error( |
| 2830 | "hyperscript errors were found on the following element:", |
| 2831 | elt, |
| 2832 | "\n\n", |
| 2833 | e.message, |
| 2834 | e.stack |
| 2835 | ); |
| 2836 | } |
| 2837 | } |
| 2838 | #resolveTemplateScopes(elt) { |
| 2839 | var root = elt.closest('[data-live-template], [dom-scope="isolated"]'); |
no test coverage detected