vue.cjs.prod.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var runtimeDom = require('@vue/runtime-dom');
  4. var shared = require('@vue/shared');
  5. var compilerDom = require('@vue/compiler-dom');
  6. function _interopNamespace(e) {
  7. if (e && e.__esModule) { return e; } else {
  8. var n = Object.create(null);
  9. if (e) {
  10. Object.keys(e).forEach(function (k) {
  11. n[k] = e[k];
  12. });
  13. }
  14. n['default'] = e;
  15. return Object.freeze(n);
  16. }
  17. }
  18. var runtimeDom__namespace = /*#__PURE__*/_interopNamespace(runtimeDom);
  19. // This entry is the "full-build" that includes both the runtime
  20. const compileCache = Object.create(null);
  21. function compileToFunction(template, options) {
  22. if (!shared.isString(template)) {
  23. if (template.nodeType) {
  24. template = template.innerHTML;
  25. }
  26. else {
  27. return shared.NOOP;
  28. }
  29. }
  30. const key = template;
  31. const cached = compileCache[key];
  32. if (cached) {
  33. return cached;
  34. }
  35. if (template[0] === '#') {
  36. const el = document.querySelector(template);
  37. // __UNSAFE__
  38. // Reason: potential execution of JS expressions in in-DOM template.
  39. // The user must make sure the in-DOM template is trusted. If it's rendered
  40. // by the server, the template should not contain any user data.
  41. template = el ? el.innerHTML : ``;
  42. }
  43. const { code } = compilerDom.compile(template, shared.extend({
  44. hoistStatic: true,
  45. onError(err) {
  46. {
  47. /* istanbul ignore next */
  48. throw err;
  49. }
  50. }
  51. }, options));
  52. // The wildcard import results in a huge object with every export
  53. // with keys that cannot be mangled, and can be quite heavy size-wise.
  54. // In the global build we know `Vue` is available globally so we can avoid
  55. // the wildcard object.
  56. const render = ( new Function('Vue', code)(runtimeDom__namespace));
  57. render._rc = true;
  58. return (compileCache[key] = render);
  59. }
  60. runtimeDom.registerRuntimeCompiler(compileToFunction);
  61. Object.keys(runtimeDom).forEach(function (k) {
  62. if (k !== 'default') exports[k] = runtimeDom[k];
  63. });
  64. exports.compile = compileToFunction;