Browse Source

only skip script tags if type is javascript (fix #2681)

Evan You 10 years ago
parent
commit
7c7c79b911
1 changed files with 9 additions and 2 deletions
  1. 9 2
      src/compiler/compile.js

+ 9 - 2
src/compiler/compile.js

@@ -53,7 +53,7 @@ export function compile (el, options, partial) {
   // link function for the childNodes
   var childLinkFn =
     !(nodeLinkFn && nodeLinkFn.terminal) &&
-    el.tagName !== 'SCRIPT' &&
+    !isScript(el) &&
     el.hasChildNodes()
       ? compileNodeList(el.childNodes, options)
       : null
@@ -284,7 +284,7 @@ export function compileRoot (el, options, contextOptions) {
 
 function compileNode (node, options) {
   var type = node.nodeType
-  if (type === 1 && node.tagName !== 'SCRIPT') {
+  if (type === 1 && !isScript(node)) {
     return compileElement(node, options)
   } else if (type === 3 && node.data.trim()) {
     return compileTextNode(node, options)
@@ -819,3 +819,10 @@ function hasOneTime (tokens) {
     if (tokens[i].oneTime) return true
   }
 }
+
+function isScript (el) {
+  return el.tagName === 'SCRIPT' && (
+    !el.hasAttribute('type') ||
+    el.getAttribute('type') === 'text/javascript'
+  )
+}