Преглед изворни кода

avoid use() a plugin more than once

Evan You пре 10 година
родитељ
комит
eab263b34a
1 измењених фајлова са 4 додато и 0 уклоњено
  1. 4 0
      src/api/global.js

+ 4 - 0
src/api/global.js

@@ -83,6 +83,9 @@ function createClass (name) {
  */
 
 exports.use = function (plugin) {
+  if (plugin.installed) {
+    return
+  }
   // additional parameters
   var args = _.toArray(arguments, 1)
   args.unshift(this)
@@ -91,6 +94,7 @@ exports.use = function (plugin) {
   } else {
     plugin.apply(null, args)
   }
+  plugin.installed = true
   return this
 }