1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | 'use strict';
|
7 |
|
8 | Object.defineProperty(exports, '__esModule', { value: true });
|
9 |
|
10 | var compilerDom = require('@vue/compiler-dom');
|
11 | var runtimeDom = require('@vue/runtime-dom');
|
12 | var shared = require('@vue/shared');
|
13 |
|
14 | function _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 |
|
25 | var runtimeDom__namespace = _interopNamespaceDefault(runtimeDom);
|
26 |
|
27 | const compileCache = Object.create(null);
|
28 | function 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 | }
|
61 | runtimeDom.registerRuntimeCompiler(compileToFunction);
|
62 |
|
63 | exports.compile = compileToFunction;
|
64 | Object.keys(runtimeDom).forEach(function (k) {
|
65 | if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = runtimeDom[k];
|
66 | });
|