UNPKG

1.77 kBJavaScriptView Raw
1/**
2* vue v3.5.13
3* (c) 2018-present Yuxi (Evan) You and Vue contributors
4* @license MIT
5**/
6'use strict';
7
8Object.defineProperty(exports, '__esModule', { value: true });
9
10var compilerDom = require('@vue/compiler-dom');
11var runtimeDom = require('@vue/runtime-dom');
12var shared = require('@vue/shared');
13
14function _interopNamespaceDefault(e) {
15 var n = Object.create(null);
16 if (e) {
17 for (var k in e) {
18 n[k] = e[k];
19 }
20 }
21 n.default = e;
22 return Object.freeze(n);
23}
24
25var runtimeDom__namespace = /*#__PURE__*/_interopNamespaceDefault(runtimeDom);
26
27const compileCache = /* @__PURE__ */ Object.create(null);
28function compileToFunction(template, options) {
29 if (!shared.isString(template)) {
30 if (template.nodeType) {
31 template = template.innerHTML;
32 } else {
33 return shared.NOOP;
34 }
35 }
36 const key = shared.genCacheKey(template, options);
37 const cached = compileCache[key];
38 if (cached) {
39 return cached;
40 }
41 if (template[0] === "#") {
42 const el = document.querySelector(template);
43 template = el ? el.innerHTML : ``;
44 }
45 const opts = shared.extend(
46 {
47 hoistStatic: true,
48 onError: void 0,
49 onWarn: shared.NOOP
50 },
51 options
52 );
53 if (!opts.isCustomElement && typeof customElements !== "undefined") {
54 opts.isCustomElement = (tag) => !!customElements.get(tag);
55 }
56 const { code } = compilerDom.compile(template, opts);
57 const render = new Function("Vue", code)(runtimeDom__namespace);
58 render._rc = true;
59 return compileCache[key] = render;
60}
61runtimeDom.registerRuntimeCompiler(compileToFunction);
62
63exports.compile = compileToFunction;
64Object.keys(runtimeDom).forEach(function (k) {
65 if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = runtimeDom[k];
66});