Skip to content

Commit 25be79c

Browse files
author
Evan You
committed
clean up
1 parent 665520f commit 25be79c

File tree

5 files changed

+20
-136
lines changed

5 files changed

+20
-136
lines changed

component.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"src/transition.js",
2424
"src/batcher.js",
2525
"src/directives/index.js",
26-
"src/directives/component.js",
2726
"src/directives/if.js",
2827
"src/directives/repeat.js",
2928
"src/directives/on.js",

src/compiler.js

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -339,13 +339,9 @@ CompilerProto.compile = function (node, root) {
339339
// special attributes to check
340340
var directive, repeatExp, viewExp, Component
341341

342-
// It is important that we access these attributes
343-
// procedurally because the order matters.
344-
// `utils.attr` removes the attribute once it gets the
345-
// value, so we should not access them all at once.
342+
// priority order for directives that create child VMs:
343+
// repeat => view => component
346344

347-
// v-repeat has the highest priority
348-
// and we need to preserve all other attributes for it.
349345
if (repeatExp = utils.attr(node, 'repeat')) {
350346

351347
// repeat block cannot have v-id at the same time.
@@ -364,7 +360,6 @@ CompilerProto.compile = function (node, root) {
364360
compiler.deferred.push(directive)
365361
}
366362

367-
// Child component has 2nd highest priority
368363
} else if (root !== true && (Component = this.resolveComponent(node, undefined, true))) {
369364

370365
directive = Directive.parse('component', '', compiler, node)
@@ -373,23 +368,8 @@ CompilerProto.compile = function (node, root) {
373368
compiler.deferred.push(directive)
374369
}
375370

376-
// should build component
377-
378-
// withExp = Directive.split(withExp || '')
379-
// withExp.forEach(function (exp, i) {
380-
// var directive = Directive.parse('with', exp, compiler, node)
381-
// if (directive) {
382-
// // notify the directive that this is the
383-
// // last expression in the group
384-
// directive.last = i === withExp.length - 1
385-
// compiler.deferred.push(directive)
386-
// }
387-
// })
388-
389371
} else {
390372

391-
// remove the component directive
392-
utils.attr(node, 'component')
393373
// compile normal directives
394374
compiler.compileNode(node)
395375

src/directives/component.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/directives/index.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,23 @@ module.exports = {
1313
style : require('./style'),
1414
partial : require('./partial'),
1515
view : require('./view'),
16-
component : require('./component'),
16+
17+
component : {
18+
isLiteral: true,
19+
bind: function () {
20+
if (!this.el.vue_vm) {
21+
this.component = new this.Ctor({
22+
el: this.el,
23+
parent: this.vm
24+
})
25+
}
26+
},
27+
unbind: function () {
28+
if (this.component) {
29+
this.component.$destroy()
30+
}
31+
}
32+
},
1733

1834
attr: {
1935
bind: function () {

src/directives/with.js

Lines changed: 1 addition & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -44,95 +44,4 @@ module.exports = {
4444
}
4545
}
4646

47-
}
48-
49-
// var utils = require('../utils')
50-
51-
// module.exports = {
52-
53-
// bind: function () {
54-
// if (this.el.vue_vm) {
55-
// this.subVM = this.el.vue_vm
56-
// var compiler = this.subVM.$compiler
57-
// if (this.arg && !compiler.bindings[this.arg]) {
58-
// compiler.createBinding(this.arg)
59-
// }
60-
// } else if (this.isEmpty) {
61-
// this.build()
62-
// }
63-
// },
64-
65-
// update: function (value, init) {
66-
// var vm = this.subVM,
67-
// key = this.arg || '$data'
68-
// if (!vm) {
69-
// this.build(value)
70-
// } else if (!this.lock && vm[key] !== value) {
71-
// vm[key] = value
72-
// }
73-
// if (init) {
74-
// // watch after first set
75-
// this.watch()
76-
// // The v-with directive can have multiple expressions,
77-
// // and we want to make sure when the ready hook is called
78-
// // on the subVM, all these clauses have been properly set up.
79-
// // So this is a hack that sniffs whether we have reached
80-
// // the last expression. We hold off the subVM's ready hook
81-
// // until we are actually ready.
82-
// if (this.last) {
83-
// this.subVM.$compiler.execHook('ready')
84-
// }
85-
// }
86-
// },
87-
88-
// build: function (value) {
89-
// var data = value
90-
// if (this.arg) {
91-
// data = {}
92-
// data[this.arg] = value
93-
// }
94-
// var Ctor = this.compiler.resolveComponent(this.el, data)
95-
// this.subVM = new Ctor({
96-
// el : this.el,
97-
// data : data,
98-
// parent : this.vm,
99-
// compilerOptions: {
100-
// // it is important to delay the ready hook
101-
// // so that when it's called, all `v-with` wathcers
102-
// // would have been set up.
103-
// delayReady: !this.last
104-
// }
105-
// })
106-
// // mark that this VM is created by v-with
107-
// utils.defProtected(this.subVM, '$with', true)
108-
// },
109-
110-
// /**
111-
// * For inhertied keys, need to watch
112-
// * and sync back to the parent
113-
// */
114-
// watch: function () {
115-
// if (!this.arg) return
116-
// var self = this,
117-
// key = self.key,
118-
// ownerVM = self.binding.compiler.vm
119-
// this.subVM.$compiler.observer.on('change:' + this.arg, function (val) {
120-
// if (!self.lock) {
121-
// self.lock = true
122-
// utils.nextTick(function () {
123-
// self.lock = false
124-
// })
125-
// }
126-
// ownerVM.$set(key, val)
127-
// })
128-
// },
129-
130-
// unbind: function () {
131-
// // all watchers are turned off during destroy
132-
// // so no need to worry about it
133-
// if (this.subVM.$with) {
134-
// this.subVM.$destroy()
135-
// }
136-
// }
137-
138-
// }
47+
}

0 commit comments

Comments
 (0)