vue.cjs.prod.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. // This entry is the "full-build" that includes both the runtime
  18. const compileCache = Object.create(null);
  19. function compileToFunction(template, options) {
  20. if (!shared.isString(template)) {
  21. if (template.nodeType) {
  22. template = template.innerHTML;
  23. }
  24. else {
  25. return shared.NOOP;
  26. }
  27. }
  28. const key = template;
  29. const cached = compileCache[key];
  30. if (cached) {
  31. return cached;
  32. }
  33. if (template[0] === '#') {
  34. const el = document.querySelector(template);
  35. // __UNSAFE__
  36. // Reason: potential execution of JS expressions in in-DOM template.
  37. // The user must make sure the in-DOM template is trusted. If it's rendered
  38. // by the server, the template should not contain any user data.
  39. template = el ? el.innerHTML : ``;
  40. }
  41. const opts = shared.extend({
  42. hoistStatic: true,
  43. onError: undefined,
  44. onWarn: shared.NOOP
  45. }, options);
  46. if (!opts.isCustomElement && typeof customElements !== 'undefined') {
  47. opts.isCustomElement = tag => !!customElements.get(tag);
  48. }
  49. const { code } = compilerDom.compile(template, opts);
  50. // The wildcard import results in a huge object with every export
  51. // with keys that cannot be mangled, and can be quite heavy size-wise.
  52. // In the global build we know `Vue` is available globally so we can avoid
  53. // the wildcard object.
  54. const render = (new Function('Vue', code)(runtimeDom__namespace));
  55. render._rc = true;
  56. return (compileCache[key] = render);
  57. }
  58. runtimeDom.registerRuntimeCompiler(compileToFunction);
  59. exports.compile = compileToFunction;
  60. Object.keys(runtimeDom).forEach(function(k) {
  61. if (k !== 'default') exports[k] = runtimeDom[k];
  62. });