Răsfoiți Sursa

init comments

Evan You 11 ani în urmă
părinte
comite
9f6ef85005
2 a modificat fișierele cu 15 adăugiri și 12 ștergeri
  1. 1 0
      grunt/tasks/build.js
  2. 14 12
      src/instance/init.js

+ 1 - 0
grunt/tasks/build.js

@@ -26,6 +26,7 @@ module.exports = function (grunt) {
         fromString: true,
         compress: {
           pure_funcs: [
+            'require',
             '_.log',
             '_.warn',
             '_.assertAsset',

+ 14 - 12
src/instance/init.js

@@ -18,24 +18,25 @@ exports._init = function (options) {
   this.$el           = null
   this.$parent       = options._parent
   this.$root         = options._root || this
-  this.$             = {}
-  this._watcherList  = []
-  this._watchers     = {}
-  this._userWatchers = {}
-  this._directives   = []
+  this.$             = {} // child vm references
+  this.$$            = {} // element references
+  this._watcherList  = [] // all watchers as an array
+  this._watchers     = {} // internal watchers as a hash
+  this._userWatchers = {} // user watchers as a hash
+  this._directives   = [] // all directives
 
   // a flag to avoid this being observed
   this._isVue = true
 
   // events bookkeeping
-  this._events         = {}
-  this._eventsCount    = {}
-  this._eventCancelled = false
+  this._events         = {}    // registered callbacks
+  this._eventsCount    = {}    // for $broadcast optimization
+  this._eventCancelled = false // for event cancellation
 
   // block instance properties
-  this._blockStart  =
-  this._blockEnd    = null
   this._isBlock     = false
+  this._blockStart  =          // @type {CommentNode}
+  this._blockEnd    = null     // @type {CommentNode}
 
   // lifecycle state
   this._isCompiled  =
@@ -45,8 +46,9 @@ exports._init = function (options) {
   this._isBeingDestroyed = false
 
   // children
-  this._children =
-  this._childCtors = null
+  this._children =         // @type {Array}
+  this._childCtors = null  // @type {Object} - hash to cache
+                           // child constructors
 
   // anonymous instances are created by v-if
   this._isAnonymous = options._anonymous