vue.cjs.prod.js 1.9 KB

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