|
1 | 1 | var _ = require('../util')
|
| 2 | +var config = require('../config') |
2 | 3 | var isObject = _.isObject
|
3 | 4 | var isPlainObject = _.isPlainObject
|
4 | 5 | var textParser = require('../parsers/text')
|
@@ -28,29 +29,37 @@ module.exports = {
|
28 | 29 | }
|
29 | 30 | // uid as a cache identifier
|
30 | 31 | this.id = '__v_repeat_' + (++uid)
|
| 32 | + |
31 | 33 | // setup anchor nodes
|
32 | 34 | this.start = _.createAnchor('v-repeat-start')
|
33 | 35 | this.end = _.createAnchor('v-repeat-end')
|
34 | 36 | _.replace(this.el, this.end)
|
35 | 37 | _.before(this.start, this.end)
|
| 38 | + |
36 | 39 | // check if this is a block repeat
|
37 | 40 | this.template = _.isTemplate(this.el)
|
38 | 41 | ? templateParser.parse(this.el, true)
|
39 | 42 | : this.el
|
40 |
| - // check other directives that need to be handled |
41 |
| - // at v-repeat level |
42 |
| - this.checkIf() |
43 |
| - this.checkRef() |
44 |
| - this.checkComponent() |
| 43 | + |
45 | 44 | // check for trackby param
|
46 |
| - this.idKey = |
47 |
| - this._checkParam('track-by') || |
48 |
| - this._checkParam('trackby') // 0.11.0 compat |
| 45 | + this.idKey = this._checkParam('track-by') |
49 | 46 | // check for transition stagger
|
50 | 47 | var stagger = +this._checkParam('stagger')
|
51 | 48 | this.enterStagger = +this._checkParam('enter-stagger') || stagger
|
52 | 49 | this.leaveStagger = +this._checkParam('leave-stagger') || stagger
|
| 50 | + |
| 51 | + // check for v-ref/v-el |
| 52 | + this.refID = this._checkParam(config.prefix + 'ref') |
| 53 | + this.elID = this._checkParam(config.prefix + 'el') |
| 54 | + |
| 55 | + // check other directives that need to be handled |
| 56 | + // at v-repeat level |
| 57 | + this.checkIf() |
| 58 | + this.checkComponent() |
| 59 | + |
| 60 | + // create cache object |
53 | 61 | this.cache = Object.create(null)
|
| 62 | + |
54 | 63 | // some helpful tips...
|
55 | 64 | /* istanbul ignore if */
|
56 | 65 | if (
|
@@ -78,21 +87,6 @@ module.exports = {
|
78 | 87 | }
|
79 | 88 | },
|
80 | 89 |
|
81 |
| - /** |
82 |
| - * Check if v-ref/ v-el is also present. |
83 |
| - */ |
84 |
| - |
85 |
| - checkRef: function () { |
86 |
| - var refID = _.attr(this.el, 'ref') |
87 |
| - this.refID = refID |
88 |
| - ? this.vm.$interpolate(refID) |
89 |
| - : null |
90 |
| - var elId = _.attr(this.el, 'el') |
91 |
| - this.elId = elId |
92 |
| - ? this.vm.$interpolate(elId) |
93 |
| - : null |
94 |
| - }, |
95 |
| - |
96 | 90 | /**
|
97 | 91 | * Check the component constructor to use for repeated
|
98 | 92 | * instances. If static we resolve it now, otherwise it
|
@@ -226,8 +220,8 @@ module.exports = {
|
226 | 220 | ? toRefObject(this.vms)
|
227 | 221 | : this.vms
|
228 | 222 | }
|
229 |
| - if (this.elId) { |
230 |
| - this.vm.$$[this.elId] = this.vms.map(function (vm) { |
| 223 | + if (this.elID) { |
| 224 | + this.vm.$$[this.elID] = this.vms.map(function (vm) { |
231 | 225 | return vm.$el
|
232 | 226 | })
|
233 | 227 | }
|
|
0 commit comments