Просмотр исходного кода

fix #569 script tags not skipped properly

Evan You 11 лет назад
Родитель
Сommit
b3faa27118
2 измененных файлов с 11 добавлено и 2 удалено
  1. 4 2
      src/compile/compile.js
  2. 7 0
      test/unit/specs/compile/compile_spec.js

+ 4 - 2
src/compile/compile.js

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

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

@@ -196,5 +196,12 @@ if (_.inBrowser) {
       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)
+    })
+
   })
 }