Ver Fonte

fix tests for IE9/10

Evan You há 11 anos atrás
pai
commit
b80ec1bfbe
2 ficheiros alterados com 7 adições e 1 exclusões
  1. 4 1
      src/compile/compile.js
  2. 3 0
      test/unit/specs/util/dom_spec.js

+ 4 - 1
src/compile/compile.js

@@ -169,7 +169,10 @@ function compileTextNode (node, options) {
           token.def = dirs.partial
           token.descriptor = dirParser.parse(value)[0]
         } else {
-          el = document.createTextNode('')
+          // IE will clean up empty textNodes during
+          // frag.cloneNode(true), so we have to give it
+          // something here...
+          el = document.createTextNode(' ')
           token.type = 'text'
           token.def = dirs.text
           token.descriptor = dirParser.parse(value)[0]

+ 3 - 0
test/unit/specs/util/dom_spec.js

@@ -87,6 +87,8 @@ if (_.inBrowser) {
     })
 
     it('on/off', function () {
+      // IE requires element to be in document to fire events
+      document.body.appendChild(target)
       var spy = jasmine.createSpy()
       _.on(target, 'click', spy)
       var e = document.createEvent('HTMLEvents')
@@ -97,6 +99,7 @@ if (_.inBrowser) {
       _.off(target, 'click', spy)
       target.dispatchEvent(e)
       expect(spy.calls.count()).toBe(1)
+      document.body.removeChild(target)
     })
   })
 }