|
|
@@ -1,4 +1,5 @@
|
|
|
var _ = require('../util')
|
|
|
+var config = require('../config')
|
|
|
var isObject = _.isObject
|
|
|
var isPlainObject = _.isPlainObject
|
|
|
var textParser = require('../parsers/text')
|
|
|
@@ -28,29 +29,37 @@ module.exports = {
|
|
|
}
|
|
|
// uid as a cache identifier
|
|
|
this.id = '__v_repeat_' + (++uid)
|
|
|
+
|
|
|
// setup anchor nodes
|
|
|
this.start = _.createAnchor('v-repeat-start')
|
|
|
this.end = _.createAnchor('v-repeat-end')
|
|
|
_.replace(this.el, this.end)
|
|
|
_.before(this.start, this.end)
|
|
|
+
|
|
|
// check if this is a block repeat
|
|
|
this.template = _.isTemplate(this.el)
|
|
|
? templateParser.parse(this.el, true)
|
|
|
: this.el
|
|
|
- // check other directives that need to be handled
|
|
|
- // at v-repeat level
|
|
|
- this.checkIf()
|
|
|
- this.checkRef()
|
|
|
- this.checkComponent()
|
|
|
+
|
|
|
// check for trackby param
|
|
|
- this.idKey =
|
|
|
- this._checkParam('track-by') ||
|
|
|
- this._checkParam('trackby') // 0.11.0 compat
|
|
|
+ this.idKey = this._checkParam('track-by')
|
|
|
// check for transition stagger
|
|
|
var stagger = +this._checkParam('stagger')
|
|
|
this.enterStagger = +this._checkParam('enter-stagger') || stagger
|
|
|
this.leaveStagger = +this._checkParam('leave-stagger') || stagger
|
|
|
+
|
|
|
+ // check for v-ref/v-el
|
|
|
+ this.refID = this._checkParam(config.prefix + 'ref')
|
|
|
+ this.elID = this._checkParam(config.prefix + 'el')
|
|
|
+
|
|
|
+ // check other directives that need to be handled
|
|
|
+ // at v-repeat level
|
|
|
+ this.checkIf()
|
|
|
+ this.checkComponent()
|
|
|
+
|
|
|
+ // create cache object
|
|
|
this.cache = Object.create(null)
|
|
|
+
|
|
|
// some helpful tips...
|
|
|
/* istanbul ignore if */
|
|
|
if (
|
|
|
@@ -78,21 +87,6 @@ module.exports = {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- /**
|
|
|
- * Check if v-ref/ v-el is also present.
|
|
|
- */
|
|
|
-
|
|
|
- checkRef: function () {
|
|
|
- var refID = _.attr(this.el, 'ref')
|
|
|
- this.refID = refID
|
|
|
- ? this.vm.$interpolate(refID)
|
|
|
- : null
|
|
|
- var elId = _.attr(this.el, 'el')
|
|
|
- this.elId = elId
|
|
|
- ? this.vm.$interpolate(elId)
|
|
|
- : null
|
|
|
- },
|
|
|
-
|
|
|
/**
|
|
|
* Check the component constructor to use for repeated
|
|
|
* instances. If static we resolve it now, otherwise it
|
|
|
@@ -226,8 +220,8 @@ module.exports = {
|
|
|
? toRefObject(this.vms)
|
|
|
: this.vms
|
|
|
}
|
|
|
- if (this.elId) {
|
|
|
- this.vm.$$[this.elId] = this.vms.map(function (vm) {
|
|
|
+ if (this.elID) {
|
|
|
+ this.vm.$$[this.elID] = this.vms.map(function (vm) {
|
|
|
return vm.$el
|
|
|
})
|
|
|
}
|