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