Răsfoiți Sursa

prohibit mounting to body/html

Evan You 9 ani în urmă
părinte
comite
16ce0f13d5
1 a modificat fișierele cu 8 adăugiri și 0 ștergeri
  1. 8 0
      src/entries/web-runtime-with-compiler.js

+ 8 - 0
src/entries/web-runtime-with-compiler.js

@@ -16,6 +16,14 @@ Vue.prototype.$mount = function (
   hydrating?: boolean
 ): Component {
   el = el && query(el)
+
+  if (el === document.body || el === document.documentElement) {
+    process.env.NODE_ENV !== 'production' && warn(
+      `Do not mount Vue to <html> or <body> - mount to normal elements instead.`
+    )
+    return this
+  }
+
   const options = this.$options
   // resolve template/el and convert to render function
   if (!options.render) {