Przeglądaj źródła

fix #569 script tags not skipped properly

Evan You 11 lat temu
rodzic
commit
b3faa27118

+ 4 - 2
src/compile/compile.js

@@ -25,7 +25,8 @@ module.exports = function compile (el, options, partial) {
     ? null
     ? null
     : compileNode(el, options)
     : compileNode(el, options)
   var childLinkFn =
   var childLinkFn =
-    (!nodeLinkFn || !nodeLinkFn.terminal) &&
+    !(nodeLinkFn && nodeLinkFn.terminal) &&
+    el.tagName !== 'SCRIPT' &&
     el.hasChildNodes()
     el.hasChildNodes()
       ? compileNodeList(el.childNodes, options)
       ? compileNodeList(el.childNodes, options)
       : null
       : null
@@ -266,7 +267,8 @@ function compileNodeList (nodeList, options) {
     node = nodeList[i]
     node = nodeList[i]
     nodeLinkFn = compileNode(node, options)
     nodeLinkFn = compileNode(node, options)
     childLinkFn =
     childLinkFn =
-      (!nodeLinkFn || !nodeLinkFn.terminal) &&
+      !(nodeLinkFn && nodeLinkFn.terminal) &&
+      node.tagName !== 'SCRIPT' &&
       node.hasChildNodes()
       node.hasChildNodes()
         ? compileNodeList(node.childNodes, options)
         ? compileNodeList(node.childNodes, options)
         : null
         : null

+ 7 - 0
test/unit/specs/compile/compile_spec.js

@@ -196,5 +196,12 @@ if (_.inBrowser) {
       expect(vm._directives.length).toBe(0)
       expect(vm._directives.length).toBe(0)
     })
     })
 
 
+    it('skip script tags', function () {
+      el.innerHTML = '<script type="x/template">{{test}}</script>'
+      var linker = compile(el, Vue.options)
+      linker(vm, el)
+      expect(vm._bindDir.calls.count()).toBe(0)
+    })
+
   })
   })
 }
 }