From 4f5a47d750d4d8b61fe3b5b2251a0a63b391ac27 Mon Sep 17 00:00:00 2001 From: Chris Fritz Date: Fri, 14 Oct 2016 09:27:54 -0400 Subject: [PATCH] fix root v-else not rendering in prod and switched examples to minified vue for better prod coverage (#3943) * fix root v-else not rendering in production and switched examples to minified vue for better prod coverage * add dev build comment to examples * convert tabs to spaces in todomvc example for consistency --- examples/commits/index.html | 3 +- examples/elastic-header/index.html | 3 +- examples/firebase/index.html | 3 +- examples/grid/index.html | 6 +- examples/markdown/index.html | 3 +- examples/modal/index.html | 3 +- examples/move-animations/index.html | 3 +- examples/select2/index.html | 3 +- examples/svg/index.html | 3 +- examples/todomvc/index.html | 129 ++++++++++++++-------------- examples/tree/index.html | 3 +- package.json | 2 +- src/compiler/parser/index.js | 8 +- test/e2e/specs/grid.js | 6 ++ 14 files changed, 99 insertions(+), 79 deletions(-) diff --git a/examples/commits/index.html b/examples/commits/index.html index a80eaa46..116fb86f 100644 --- a/examples/commits/index.html +++ b/examples/commits/index.html @@ -18,7 +18,8 @@ font-weight: bold; } - + +
diff --git a/examples/elastic-header/index.html b/examples/elastic-header/index.html index 63f75fa0..81df1c94 100644 --- a/examples/elastic-header/index.html +++ b/examples/elastic-header/index.html @@ -4,7 +4,8 @@ - + + diff --git a/examples/firebase/index.html b/examples/firebase/index.html index e8c54bd5..eee783ac 100644 --- a/examples/firebase/index.html +++ b/examples/firebase/index.html @@ -5,7 +5,8 @@ - + + diff --git a/examples/grid/index.html b/examples/grid/index.html index c9d58fd4..d668cd76 100644 --- a/examples/grid/index.html +++ b/examples/grid/index.html @@ -4,13 +4,14 @@ Vue.js grid component example - + + diff --git a/examples/markdown/index.html b/examples/markdown/index.html index 42f228fa..9ca98746 100644 --- a/examples/markdown/index.html +++ b/examples/markdown/index.html @@ -6,7 +6,8 @@ - + + diff --git a/examples/modal/index.html b/examples/modal/index.html index 5f530ab9..302e9470 100644 --- a/examples/modal/index.html +++ b/examples/modal/index.html @@ -3,7 +3,8 @@ Vue.js Modal Example - + + diff --git a/examples/move-animations/index.html b/examples/move-animations/index.html index dc0f80e0..ae246607 100644 --- a/examples/move-animations/index.html +++ b/examples/move-animations/index.html @@ -29,7 +29,8 @@ } - + +
diff --git a/examples/select2/index.html b/examples/select2/index.html index f625c8a5..b2344c6e 100644 --- a/examples/select2/index.html +++ b/examples/select2/index.html @@ -3,7 +3,8 @@ Vue.js custom directive integration example (select2) - + + diff --git a/examples/svg/index.html b/examples/svg/index.html index 7b4ca5db..faf731df 100644 --- a/examples/svg/index.html +++ b/examples/svg/index.html @@ -4,7 +4,8 @@ Vue.js SVG example - + + diff --git a/examples/todomvc/index.html b/examples/todomvc/index.html index 063229bc..0477f0d0 100644 --- a/examples/todomvc/index.html +++ b/examples/todomvc/index.html @@ -1,68 +1,69 @@ - - - Vue.js • TodoMVC - - - - - -
-
-

todos

- -
-
- -
    -
  • -
    - - - -
    - -
  • -
-
-
- - {{ remaining }} {{ remaining | pluralize }} left - - - -
-
- + + + Vue.js • TodoMVC + + + + + +
+
+

todos

+ +
+
+ +
    +
  • +
    + + + +
    + +
  • +
+
+
+ + {{ remaining }} {{ remaining | pluralize }} left + + + +
+
+ - - - - + + + + + diff --git a/examples/tree/index.html b/examples/tree/index.html index 1bb8611c..05df3206 100644 --- a/examples/tree/index.html +++ b/examples/tree/index.html @@ -20,7 +20,8 @@ list-style-type: dot; } - + + diff --git a/package.json b/package.json index c16ceefb..794bcaa4 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "test": "npm run lint && flow check && npm run test:types && npm run test:cover && npm run test:e2e -- --env phantomjs && npm run test:ssr", "test:unit": "karma start build/karma.unit.config.js", "test:cover": "karma start build/karma.cover.config.js", - "test:e2e": "npm run build -- vue.js && node test/e2e/runner.js", + "test:e2e": "npm run build -- vue.min.js && node test/e2e/runner.js", "test:ssr": "npm run build:ssr && VUE_ENV=server jasmine JASMINE_CONFIG_PATH=test/ssr/jasmine.json", "test:sauce": "npm run sauce -- 0 && npm run sauce -- 1 && npm run sauce -- 2", "test:types": "tsc -p ./types/test/tsconfig.json", diff --git a/src/compiler/parser/index.js b/src/compiler/parser/index.js index 4b51151c..4978390d 100644 --- a/src/compiler/parser/index.js +++ b/src/compiler/parser/index.js @@ -130,14 +130,16 @@ export function parse ( } function checkRootConstraints (el) { - if (process.env.NODE_ENV !== 'production') { + if (process.env.NODE_ENV !== 'production' && !warned) { if (el.tag === 'slot' || el.tag === 'template') { + warned = true warn( `Cannot use <${el.tag}> as component root element because it may ` + 'contain multiple nodes:\n' + template ) } if (el.attrsMap.hasOwnProperty('v-for')) { + warned = true warn( 'Cannot use v-for on stateful component root element because ' + 'it renders multiple elements:\n' + template @@ -150,12 +152,12 @@ export function parse ( if (!root) { root = element checkRootConstraints(root) - } else if (process.env.NODE_ENV !== 'production' && !stack.length && !warned) { + } else if (!stack.length) { // allow 2 root elements with v-if and v-else if (root.if && element.else) { checkRootConstraints(element) root.elseBlock = element - } else { + } else if (process.env.NODE_ENV !== 'production' && !warned) { warned = true warn( `Component template should contain exactly one root element:\n\n${template}` diff --git a/test/e2e/specs/grid.js b/test/e2e/specs/grid.js index ad47c8ff..7c273359 100644 --- a/test/e2e/specs/grid.js +++ b/test/e2e/specs/grid.js @@ -82,6 +82,12 @@ module.exports = { { name: 'Chuck Norris', power: Infinity } ]) + browser + .clearValue('input[name="query"]') + .assert.count('p', 0) + .setValue('input[name="query"]', 'stringthatdoesnotexistanywhere') + .assert.count('p', 1) + browser.end() function assertTable (data) {