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

use empty textNodes as anchors for cleaner HTML output

Evan You пре 11 година
родитељ
комит
5566f75782

+ 5 - 2
src/compiler/transclude.js

@@ -51,8 +51,11 @@ module.exports = function transclude (el, options) {
     el = transcludeTemplate(el, options)
   }
   if (el instanceof DocumentFragment) {
-    _.prepend(document.createComment('v-start'), el)
-    el.appendChild(document.createComment('v-end'))
+    // anchors for block instance
+    // passing in `persist: true` to avoid them being
+    // discarded by IE during template cloning
+    _.prepend(_.createAnchor('v-start', true), el)
+    el.appendChild(_.createAnchor('v-end', true))
   }
   return el
 }

+ 6 - 6
src/directives/component.js

@@ -18,8 +18,8 @@ module.exports = {
   bind: function () {
     if (!this.el.__vue__) {
       // create a ref anchor
-      this.ref = document.createComment('v-component')
-      _.replace(this.el, this.ref)
+      this.anchor = _.createAnchor('v-component')
+      _.replace(this.el, this.anchor)
       // check keep-alive options.
       // If yes, instead of destroying the active vm when
       // hiding (v-if) or switching (dynamic literal) it,
@@ -44,7 +44,7 @@ module.exports = {
       if (!this._isDynamicLiteral) {
         this.resolveCtor(this.expression, _.bind(function () {
           var child = this.build()
-          child.$before(this.ref)
+          child.$before(this.anchor)
           this.setCurrent(child)
         }, this))
       } else {
@@ -214,18 +214,18 @@ module.exports = {
     this.setCurrent(target)
     switch (self.transMode) {
       case 'in-out':
-        target.$before(self.ref, function () {
+        target.$before(self.anchor, function () {
           self.remove(current, cb)
         })
         break
       case 'out-in':
         self.remove(current, function () {
-          target.$before(self.ref, cb)
+          target.$before(self.anchor, cb)
         })
         break
       default:
         self.remove(current)
-        target.$before(self.ref, cb)
+        target.$before(self.anchor, cb)
     }
   },
 

+ 4 - 1
src/directives/html.js

@@ -9,6 +9,9 @@ module.exports = {
     if (this.el.nodeType === 8) {
       // hold nodes
       this.nodes = []
+      // replace the placeholder with proper anchor
+      this.anchor = _.createAnchor('v-html')
+      _.replace(this.el, this.anchor)
     }
   },
 
@@ -32,7 +35,7 @@ module.exports = {
     var frag = templateParser.parse(value, true, true)
     // save a reference to these nodes so we can remove later
     this.nodes = _.toArray(frag.childNodes)
-    _.before(frag, this.el)
+    _.before(frag, this.anchor)
   }
 
 }

+ 2 - 2
src/directives/if.js

@@ -8,8 +8,8 @@ module.exports = {
   bind: function () {
     var el = this.el
     if (!el.__vue__) {
-      this.start = document.createComment('v-if-start')
-      this.end = document.createComment('v-if-end')
+      this.start = _.createAnchor('v-if-start')
+      this.end = _.createAnchor('v-if-end')
       _.replace(el, this.end)
       _.before(this.start, this.end)
       if (el.tagName === 'TEMPLATE') {

+ 10 - 10
src/directives/repeat.js

@@ -37,9 +37,9 @@ module.exports = {
     } else {
       this.filters.read.unshift(objectConverter)
     }
-    // setup ref node
-    this.ref = document.createComment('v-repeat')
-    _.replace(this.el, this.ref)
+    // setup anchor node
+    this.anchor = _.createAnchor('v-repeat')
+    _.replace(this.el, this.anchor)
     // check if this is a block repeat
     this.template = this.el.tagName === 'TEMPLATE'
       ? templateParser.parse(this.el, true)
@@ -258,7 +258,7 @@ module.exports = {
   diff: function (data, oldVms) {
     var idKey = this.idKey
     var converted = this.converted
-    var ref = this.ref
+    var anchor = this.anchor
     var alias = this.arg
     var init = !oldVms
     var vms = new Array(data.length)
@@ -297,7 +297,7 @@ module.exports = {
       vms[i] = vm
       // insert if this is first run
       if (init) {
-        vm.$before(ref)
+        vm.$before(anchor)
       }
     }
     // if this is the first run, we're done.
@@ -330,13 +330,13 @@ module.exports = {
         // place, so no need to touch it. Otherwise, insert
         // it.
         if (!vm._reused) {
-          vm.$before(ref)
+          vm.$before(anchor)
         }
       } else {
         var nextEl = targetNext.$el
         if (vm._reused) {
           // this is the vm we are actually in front of
-          currentNext = findNextVm(vm, ref)
+          currentNext = findNextVm(vm, anchor)
           // we only need to move if we are not in the right
           // place already.
           if (currentNext !== targetNext) {
@@ -544,13 +544,13 @@ module.exports = {
  * should have been removed so we can skip them.
  *
  * @param {Vue} vm
- * @param {CommentNode} ref
+ * @param {Comment|Text} anchor
  * @return {Vue}
  */
 
-function findNextVm (vm, ref) {
+function findNextVm (vm, anchor) {
   var el = (vm._blockEnd || vm.$el).nextSibling
-  while (!el.__vue__ && el !== ref) {
+  while (!el.__vue__ && el !== anchor) {
     el = el.nextSibling
   }
   return el.__vue__

+ 4 - 0
src/instance/compile.js

@@ -51,6 +51,10 @@ exports._initElement = function (el) {
     this._isBlock = true
     this.$el = this._blockStart = el.firstChild
     this._blockEnd = el.lastChild
+    // set persisted text anchors to empty
+    if (this._blockStart.nodeType === 3) {
+      this._blockStart.data = this._blockEnd.data = ''
+    }
     this._blockFragment = el
   } else {
     this.$el = el

+ 26 - 0
src/util/misc.js

@@ -1,3 +1,5 @@
+var config = require('../config')
+
 /**
  * Check if an element is a component, if yes return its
  * component id.
@@ -17,4 +19,28 @@ exports.checkComponent = function (el, options) {
   } else if (options.components[tag]) {
     return tag
   }
+}
+
+/**
+ * Create an "anchor" for performing dom insertion/removals.
+ * This is used in a number of scenarios:
+ * - block instance
+ * - v-html
+ * - v-if
+ * - component
+ * - repeat
+ *
+ * @param {String} content
+ * @param {Boolean} persist - IE trashes empty textNodes on
+ *                            cloneNode(true), so in certain
+ *                            cases the anchor needs to be
+ *                            non-empty to be persisted in
+ *                            templates.
+ * @return {Comment|Text}
+ */
+
+exports.createAnchor = function (content, persist) {
+  return config.debug
+    ? document.createComment(content)
+    : document.createTextNode(persist ? ' ' : '')
 }

+ 4 - 6
test/unit/specs/compiler/compile_spec.js

@@ -257,17 +257,15 @@ if (_.inBrowser) {
       })
       expect(el.innerHTML).toBe(
         '<testa><testb>' +
-          '<div>1</div><div>2</div><!--v-repeat-->' +
-        '</testb><!--v-component-->' +
-        '</testa><!--v-component-->'
+          '<div>1</div><div>2</div>' +
+        '</testb></testa>'
       )
       vm.list.push(3)
       _.nextTick(function () {
         expect(el.innerHTML).toBe(
           '<testa><testb>' +
-            '<div>1</div><div>2</div><div>3</div><!--v-repeat-->' +
-          '</testb><!--v-component-->' +
-          '</testa><!--v-component-->'
+            '<div>1</div><div>2</div><div>3</div>' +
+          '</testb></testa>'
         )
         done()
       })

+ 4 - 4
test/unit/specs/compiler/transclude_spec.js

@@ -47,9 +47,9 @@ if (_.inBrowser) {
       var res = transclude(frag, options)
       expect(res).toBe(frag)
       expect(res.childNodes.length).toBe(3)
-      expect(res.childNodes[0].nodeType).toBe(8)
+      expect(res.childNodes[0].nodeType).toBe(3)
       expect(res.childNodes[1]).toBe(el)
-      expect(res.childNodes[2].nodeType).toBe(8)
+      expect(res.childNodes[2].nodeType).toBe(3)
     })
 
     it('template element', function () {
@@ -58,9 +58,9 @@ if (_.inBrowser) {
       var res = transclude(tpl, options)
       expect(res instanceof DocumentFragment).toBe(true)
       expect(res.childNodes.length).toBe(3)
-      expect(res.childNodes[0].nodeType).toBe(8)
+      expect(res.childNodes[0].nodeType).toBe(3)
       expect(res.childNodes[1].textContent).toBe('123')
-      expect(res.childNodes[2].nodeType).toBe(8)
+      expect(res.childNodes[2].nodeType).toBe(3)
     })
 
     it('content transclusion', function () {

+ 12 - 12
test/unit/specs/directives/component_spec.js

@@ -28,7 +28,7 @@ if (_.inBrowser) {
           }
         }
       })
-      expect(el.innerHTML).toBe('<test>123</test><!--v-component-->')
+      expect(el.innerHTML).toBe('<test>123</test>')
     })
 
     it('replace', function () {
@@ -45,7 +45,7 @@ if (_.inBrowser) {
           }
         }
       })
-      expect(el.innerHTML).toBe('<p>123</p><!--v-component-->')
+      expect(el.innerHTML).toBe('<p>123</p>')
     })
 
     it('inline-template', function () {
@@ -64,7 +64,7 @@ if (_.inBrowser) {
           }
         }
       })
-      expect(el.innerHTML).toBe('<test>child</test><!--v-component-->')
+      expect(el.innerHTML).toBe('<test>child</test>')
     })
 
     it('block replace', function () {
@@ -81,7 +81,7 @@ if (_.inBrowser) {
           }
         }
       })
-      expect(el.innerHTML).toBe('<!--v-start--><p>123</p><p>234</p><!--v-end--><!--v-component-->')
+      expect(el.innerHTML).toBe('<p>123</p><p>234</p>')
     })
 
     it('dynamic', function (done) {
@@ -108,13 +108,13 @@ if (_.inBrowser) {
           }
         }
       })
-      expect(el.innerHTML).toBe('<div view="a">AAA</div><!--v-component-->')
+      expect(el.innerHTML).toBe('<div view="a">AAA</div>')
       vm.view = 'b'
       _.nextTick(function () {
-        expect(el.innerHTML).toBe('<div view="b">BBB</div><!--v-component-->')
+        expect(el.innerHTML).toBe('<div view="b">BBB</div>')
         vm.view = ''
         _.nextTick(function () {
-          expect(el.innerHTML).toBe('<!--v-component-->')
+          expect(el.innerHTML).toBe('')
           done()
         })
       })
@@ -142,22 +142,22 @@ if (_.inBrowser) {
           }
         }
       })
-      expect(el.innerHTML).toBe('<div>AAA</div><!--v-component-->')
+      expect(el.innerHTML).toBe('<div>AAA</div>')
       expect(spyA.calls.count()).toBe(1)
       expect(spyB.calls.count()).toBe(0)
       vm.view = 'b'
       _.nextTick(function () {
-        expect(el.innerHTML).toBe('<div>BBB</div><!--v-component-->')
+        expect(el.innerHTML).toBe('<div>BBB</div>')
         expect(spyA.calls.count()).toBe(1)
         expect(spyB.calls.count()).toBe(1)
         vm.view = 'a'
         _.nextTick(function () {
-          expect(el.innerHTML).toBe('<div>AAA</div><!--v-component-->')
+          expect(el.innerHTML).toBe('<div>AAA</div>')
           expect(spyA.calls.count()).toBe(1)
           expect(spyB.calls.count()).toBe(1)
           vm.view = 'b'
           _.nextTick(function () {
-            expect(el.innerHTML).toBe('<div>BBB</div><!--v-component-->')
+            expect(el.innerHTML).toBe('<div>BBB</div>')
             expect(spyA.calls.count()).toBe(1)
             expect(spyB.calls.count()).toBe(1)
             done()
@@ -243,7 +243,7 @@ if (_.inBrowser) {
           }
         }
       })
-      expect(el.innerHTML).toBe('<ul><li>1</li><li>2</li><!--v-repeat--></ul><!--v-component-->')
+      expect(el.innerHTML).toBe('<ul><li>1</li><li>2</li></ul>')
     })
 
     it('wait-for', function (done) {

+ 4 - 4
test/unit/specs/directives/html_spec.js

@@ -24,7 +24,7 @@ if (_.inBrowser) {
     })
 
     it('inline', function () {
-      var node = document.createComment('htm-test')
+      var node = document.createComment('html-test')
       el.appendChild(node)
       var dir = {
         el: node
@@ -32,11 +32,11 @@ if (_.inBrowser) {
       _.extend(dir, def)
       dir.bind()
       dir.update('<div>1234</div><p>234</p>')
-      expect(el.innerHTML).toBe('<div>1234</div><p>234</p><!--htm-test-->')
+      expect(el.innerHTML).toBe('<div>1234</div><p>234</p>')
       dir.update('<p>123</p><div>444</div>')
-      expect(el.innerHTML).toBe('<p>123</p><div>444</div><!--htm-test-->')
+      expect(el.innerHTML).toBe('<p>123</p><div>444</div>')
       dir.update(null)
-      expect(el.innerHTML).toBe('<!--htm-test-->')
+      expect(el.innerHTML).toBe('')
     })
 
   })

+ 23 - 28
test/unit/specs/directives/if_spec.js

@@ -10,10 +10,6 @@ if (_.inBrowser) {
       spyOn(_, 'warn')
     })
 
-    function wrap (content) {
-      return '<!--v-if-start-->' + content + '<!--v-if-end-->'
-    }
-
     it('normal', function (done) {
       var vm = new Vue({
         el: el,
@@ -27,19 +23,19 @@ if (_.inBrowser) {
         }
       })
       // lazy instantitation
-      expect(el.innerHTML).toBe(wrap(''))
+      expect(el.innerHTML).toBe('')
       expect(vm._children.length).toBe(0)
       vm.test = true
       _.nextTick(function () {
-        expect(el.innerHTML).toBe(wrap('<div><test>A</test><!--v-component--></div>'))
+        expect(el.innerHTML).toBe('<div><test>A</test></div>')
         expect(vm._children.length).toBe(1)
         vm.test = false
         _.nextTick(function () {
-          expect(el.innerHTML).toBe(wrap(''))
+          expect(el.innerHTML).toBe('')
           expect(vm._children.length).toBe(0)
           vm.test = true
           _.nextTick(function () {
-            expect(el.innerHTML).toBe(wrap('<div><test>A</test><!--v-component--></div>'))
+            expect(el.innerHTML).toBe('<div><test>A</test></div>')
             expect(vm._children.length).toBe(1)
             var child = vm._children[0]
             vm.$destroy()
@@ -57,13 +53,13 @@ if (_.inBrowser) {
         template: '<template v-if="test"><p>{{a}}</p><p>{{b}}</p></template>'
       })
       // lazy instantitation
-      expect(el.innerHTML).toBe(wrap(''))
+      expect(el.innerHTML).toBe('')
       vm.test = true
       _.nextTick(function () {
-        expect(el.innerHTML).toBe(wrap('<p>A</p><p>B</p>'))
+        expect(el.innerHTML).toBe('<p>A</p><p>B</p>')
         vm.test = false
         _.nextTick(function () {
-          expect(el.innerHTML).toBe(wrap(''))
+          expect(el.innerHTML).toBe('')
           done()
         })
       })
@@ -90,18 +86,18 @@ if (_.inBrowser) {
         }
       })
       vm.$appendTo(document.body)
-      expect(el.innerHTML).toBe(wrap(''))
+      expect(el.innerHTML).toBe('')
       expect(vm._children.length).toBe(0)
       vm.ok = true
       _.nextTick(function () {
-        expect(el.innerHTML).toBe(wrap('<test>123</test><!--v-component-->'))
+        expect(el.innerHTML).toBe('<test>123</test>')
         expect(vm._children.length).toBe(1)
         expect(attachSpy).toHaveBeenCalled()
         expect(readySpy).toHaveBeenCalled()
         vm.ok = false
         _.nextTick(function () {
           expect(detachSpy).toHaveBeenCalled()
-          expect(el.innerHTML).toBe(wrap(''))
+          expect(el.innerHTML).toBe('')
           expect(vm._children.length).toBe(0)
           vm.$remove()
           done()
@@ -126,28 +122,28 @@ if (_.inBrowser) {
           }
         }
       })
-      expect(el.innerHTML).toBe(wrap(''))
+      expect(el.innerHTML).toBe('')
       expect(vm._children.length).toBe(0)
       // toggle if with lazy instantiation
       vm.ok = true
       _.nextTick(function () {
-        expect(el.innerHTML).toBe(wrap('<component>AAA</component><!--v-component-->'))
+        expect(el.innerHTML).toBe('<component>AAA</component>')
         expect(vm._children.length).toBe(1)
         // switch view when if=true
         vm.view = 'b'
         _.nextTick(function () {
-          expect(el.innerHTML).toBe(wrap('<component>BBB</component><!--v-component-->'))
+          expect(el.innerHTML).toBe('<component>BBB</component>')
           expect(vm._children.length).toBe(1)
           // toggle if when already instantiated
           vm.ok = false
           _.nextTick(function () {
-            expect(el.innerHTML).toBe(wrap(''))
+            expect(el.innerHTML).toBe('')
             expect(vm._children.length).toBe(0)
             // toggle if and switch view at the same time
             vm.view = 'a'
             vm.ok = true
             _.nextTick(function () {
-              expect(el.innerHTML).toBe(wrap('<component>AAA</component><!--v-component-->'))
+              expect(el.innerHTML).toBe('<component>AAA</component>')
               expect(vm._children.length).toBe(1)
               done()
             })
@@ -164,10 +160,10 @@ if (_.inBrowser) {
         },
         template: '<div v-if="a">{{a}}</div>'
       })
-      expect(el.innerHTML).toBe(wrap('<div>1</div>'))
+      expect(el.innerHTML).toBe('<div>1</div>')
       vm.a = 2
       _.nextTick(function () {
-        expect(el.innerHTML).toBe(wrap('<div>2</div>'))
+        expect(el.innerHTML).toBe('<div>2</div>')
         done()
       })
     })
@@ -301,15 +297,14 @@ if (_.inBrowser) {
           ? '<div><div>' +
               vm.list.map(function (o) {
                 return '<transcluded>' + o.a + '</transcluded>'
-              }).join('') + '<!--v-repeat-->' +
+              }).join('') +
             '</div></div>'
           : ''
-        var markup = '<outer>' +
-          '<!--v-if-start-->' +
-            showBlock +
-          '<!--v-if-end-->' +
-          '<transcluded></transcluded><!--v-component-->' +
-        '</outer><!--v-component-->'
+        var markup =
+          '<outer>' +
+              showBlock +
+            '<transcluded></transcluded>' +
+          '</outer>'
         expect(el.innerHTML).toBe(markup)
       }
     })

+ 1 - 1
test/unit/specs/directives/prop_spec.js

@@ -101,7 +101,7 @@ if (_.inBrowser) {
           }
         }
       })
-      expect(el.innerHTML).toBe('<!--v-start--><p>AAA</p><p>DDD</p><!--v-end--><!--v-component-->')
+      expect(el.innerHTML).toBe('<p>AAA</p><p>DDD</p>')
     })
 
   })

+ 29 - 32
test/unit/specs/directives/repeat_spec.js

@@ -120,7 +120,7 @@ if (_.inBrowser) {
       })
       var markup = vm.items.map(function (item, i) {
         return '<div>' + i + ' ' + item.toString() + '</div>'
-      }).join('') + '<!--v-repeat-->'
+      }).join('')
       expect(el.innerHTML).toBe(markup)
     })
 
@@ -135,7 +135,7 @@ if (_.inBrowser) {
         },
         template: '<div v-repeat="items | filterBy \'aaa\'">{{msg}}</div>'
       })
-      expect(el.innerHTML).toBe('<div>aaa</div><!--v-repeat-->')
+      expect(el.innerHTML).toBe('<div>aaa</div>')
     })
 
     it('component', function (done) {
@@ -223,9 +223,8 @@ if (_.inBrowser) {
           '</div>'
       })
       expect(el.innerHTML).toBe(
-        '<div><p>0 1 0 1</p><p>1 2 0 1</p><!--v-repeat--></div>' +
-        '<div><p>0 3 1 2</p><p>1 4 1 2</p><!--v-repeat--></div>' +
-        '<!--v-repeat-->'
+        '<div><p>0 1 0 1</p><p>1 2 0 1</p></div>' +
+        '<div><p>0 3 1 2</p><p>1 4 1 2</p></div>'
       )
     })
 
@@ -244,9 +243,8 @@ if (_.inBrowser) {
       })
       function output(key){
         var key1 = key === 'listA' ? 'listB' : 'listA'
-        return  '<div>'+ key +'<p>1</p><p>2</p><!--v-repeat--></div>' +
-                '<div>'+ key1 +'<p>1</p><p>2</p><!--v-repeat--></div>' +
-                '<!--v-repeat-->'
+        return  '<div>'+ key +'<p>1</p><p>2</p></div>' +
+                '<div>'+ key1 +'<p>1</p><p>2</p></div>'
       }
       expect(el.innerHTML === output('listA') || el.innerHTML === output('listB')).toBeTruthy()
     })
@@ -274,7 +272,7 @@ if (_.inBrowser) {
           }
         }
       })
-      expect(el.innerHTML).toBe('<component>AAA</component><component>BBB</component><component>CCC</component><!--v-repeat-->')
+      expect(el.innerHTML).toBe('<component>AAA</component><component>BBB</component><component>CCC</component>')
       // #458 meta properties
       vm = new Vue({
         el: el,
@@ -294,7 +292,7 @@ if (_.inBrowser) {
           }
         }
       })
-      expect(el.innerHTML).toBe('<component>AAA</component><component>BBB</component><component>CCC</component><!--v-repeat-->')
+      expect(el.innerHTML).toBe('<component>AAA</component><component>BBB</component><component>CCC</component>')
     })
 
     it('block repeat', function (done) {
@@ -318,9 +316,9 @@ if (_.inBrowser) {
 
       function assertMarkup () {
         var markup = vm.list.map(function (item) {
-          return '<!--v-start--><p>' + item.a + '</p><p>' + (item.a + 1) + '</p><!--v-end-->'
+          return '<p>' + item.a + '</p><p>' + (item.a + 1) + '</p>'
         }).join('')
-        expect(el.innerHTML).toBe(markup + '<!--v-repeat-->')
+        expect(el.innerHTML).toBe(markup)
       }
     })
 
@@ -343,13 +341,13 @@ if (_.inBrowser) {
       var markup = vm.list.map(function (item) {
         return '<div class="child parent">' + item.a + ' hi</div>'
       }).join('')
-      expect(el.innerHTML).toBe(markup + '<!--v-repeat-->')
+      expect(el.innerHTML).toBe(markup)
       vm.msg = 'ho'
       markup = vm.list.map(function (item) {
         return '<div class="child parent">' + item.a + ' ho</div>'
       }).join('')
       _.nextTick(function () {
-        expect(el.innerHTML).toBe(markup + '<!--v-repeat-->')
+        expect(el.innerHTML).toBe(markup)
         done()
       })
     })
@@ -412,7 +410,7 @@ if (_.inBrowser) {
           .map(function (item) {
             return '<div>' + item.id + '</div>'
           }).join('')
-        expect(el.innerHTML).toBe(markup + '<!--v-repeat-->')
+        expect(el.innerHTML).toBe(markup)
       }
     })
 
@@ -429,10 +427,10 @@ if (_.inBrowser) {
           }
         }
       })
-      expect(el.innerHTML).toBe('<div>3</div><div>2</div><div>1</div><!--v-repeat-->')
+      expect(el.innerHTML).toBe('<div>3</div><div>2</div><div>1</div>')
       vm.sortKey = '$value'
       _.nextTick(function () {
-        expect(el.innerHTML).toBe('<div>1</div><div>2</div><div>3</div><!--v-repeat-->')
+        expect(el.innerHTML).toBe('<div>1</div><div>2</div><div>3</div>')
         done()
       })
     })
@@ -445,7 +443,7 @@ if (_.inBrowser) {
           list: [3, 2, 1]
         }
       })
-      expect(el.innerHTML).toBe('<div>1</div><div>2</div><div>3</div><!--v-repeat-->')
+      expect(el.innerHTML).toBe('<div>1</div><div>2</div><div>3</div>')
     })
 
     it('track by id', function (done) {
@@ -493,7 +491,7 @@ if (_.inBrowser) {
           var markup = vm.list.map(function (item) {
             return '<test>' + item.msg + '</test>'
           }).join('')
-          expect(el.innerHTML).toBe(markup + '<!--v-repeat-->')
+          expect(el.innerHTML).toBe(markup)
         }
       }
     })
@@ -543,7 +541,7 @@ if (_.inBrowser) {
         el: el,
         template: '<div v-repeat="3">{{$index}} {{$value}}</div>'
       })
-      expect(el.innerHTML).toBe('<div>0 0</div><div>1 1</div><div>2 2</div><!--v-repeat-->')
+      expect(el.innerHTML).toBe('<div>0 0</div><div>1 1</div><div>2 2</div>')
     })
 
     it('repeat string', function () {
@@ -551,7 +549,7 @@ if (_.inBrowser) {
         el: el,
         template: '<div v-repeat="\'vue\'">{{$index}} {{$value}}</div>'
       })
-      expect(el.innerHTML).toBe('<div>0 v</div><div>1 u</div><div>2 e</div><!--v-repeat-->')
+      expect(el.innerHTML).toBe('<div>0 v</div><div>1 u</div><div>2 e</div>')
     })
 
     it('teardown', function () {
@@ -580,17 +578,17 @@ if (_.inBrowser) {
         transitions: {
           test: {
             leave: function (el, done) {
-              setTimeout(done, 1)
+              setTimeout(done, 0)
             }
           }
         }
       })
       vm.items.splice(1, 1, {a:4})
       setTimeout(function () {
-        expect(el.innerHTML).toBe('<div>1</div><div>4</div><div>3</div><!--v-repeat-->')
+        expect(el.innerHTML).toBe('<div>1</div><div>4</div><div>3</div>')
         document.body.removeChild(el)
         done()
-      }, 30)
+      }, 100)
     })
 
     it('sync $value changes back to original array/object', function (done) {
@@ -660,9 +658,9 @@ if (_.inBrowser) {
           var markup = vm.list.map(function (item) {
             var sublist = item.list.map(function (item) {
               return '<div>' + item.msg + '</div>'
-            }).join('') + '<!--v-repeat-->'
+            }).join('')
             return '<div>' + item.msg + sublist + '</div>'
-          }).join('') + '<!--v-repeat-->'
+          }).join('')
           expect(el.innerHTML).toBe(markup)
         }
       }
@@ -703,7 +701,7 @@ function go (fn, cb) {
  * an Array of Objects
  */
 
-function assertMutations (vm, el, done, isBlock) {
+function assertMutations (vm, el, done) {
   assertMarkup()
   var poppedItem
   go(
@@ -763,10 +761,9 @@ function assertMutations (vm, el, done, isBlock) {
     var tag = el.children[0].tagName.toLowerCase()
     var markup = vm.items.map(function (item, i) {
       var el = '<' + tag + '>' + i + ' ' + item.a + '</' + tag + '>'
-      if (isBlock) el = '<!--v-start-->' + el + '<!--v-end-->'
       return el
     }).join('')
-    expect(el.innerHTML).toBe(markup + '<!--v-repeat-->')
+    expect(el.innerHTML).toBe(markup)
   }
 }
 
@@ -835,7 +832,7 @@ function assertPrimitiveMutations (vm, el, done) {
     var markup = vm.items.map(function (item, i) {
       return '<div>' + i + ' ' + item + '</div>'
     }).join('')
-    expect(el.innerHTML).toBe(markup + '<!--v-repeat-->')
+    expect(el.innerHTML).toBe(markup)
   }
 }
 
@@ -873,7 +870,7 @@ function assertObjectMutations (vm, el, done) {
     var markup = Object.keys(vm.items).map(function (key, i) {
       return '<div>' + i + ' ' + key + ' ' + vm.items[key].a + '</div>'
     }).join('')
-    expect(el.innerHTML).toBe(markup + '<!--v-repeat-->')
+    expect(el.innerHTML).toBe(markup)
   }
 }
 
@@ -911,6 +908,6 @@ function assertObjectPrimitiveMutations (vm, el, done) {
     var markup = Object.keys(vm.items).map(function (key, i) {
       return '<div>' + i + ' ' + key + ' ' + vm.items[key] + '</div>'
     }).join('')
-    expect(el.innerHTML).toBe(markup + '<!--v-repeat-->')
+    expect(el.innerHTML).toBe(markup)
   }
 }

+ 1 - 5
test/unit/specs/misc_spec.js

@@ -62,11 +62,7 @@ describe('Misc', function () {
         }
       }
     })
-    expect(vm.$el.innerHTML).toBe(
-      '<!--v-start-->' +
-      '<div>1</div><div>2</div><div>3</div><!--v-repeat-->' +
-      '<!--v-end--><!--v-component-->'
-    )
+    expect(vm.$el.innerHTML).toBe('<div>1</div><div>2</div><div>3</div>')
   })
 
 })