Skip to content

Commit 4f5a47d

Browse files
chrisvfritzyyx990803
authored andcommitted
fix root v-else not rendering in prod and switched examples to minified vue for better prod coverage (vuejs#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
1 parent 95bf0c0 commit 4f5a47d

File tree

14 files changed

+99
-79
lines changed

14 files changed

+99
-79
lines changed

Diff for: examples/commits/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
font-weight: bold;
1919
}
2020
</style>
21-
<script src="../../dist/vue.js"></script>
21+
<!-- Delete ".min" for console warnings in development -->
22+
<script src="../../dist/vue.min.js"></script>
2223
</head>
2324
<body>
2425
<div id="demo">

Diff for: examples/elastic-header/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
<meta charset="utf-8">
55
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
66
<title></title>
7-
<script src="../../dist/vue.js"></script>
7+
<!-- Delete ".min" for console warnings in development -->
8+
<script src="../../dist/vue.min.js"></script>
89
<script src="http://dynamicsjs.com/lib/dynamics.js"></script>
910
<link rel="stylesheet" href="style.css">
1011
<!-- template for the component -->

Diff for: examples/firebase/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
<meta charset="utf-8">
66
<link rel="stylesheet" type="text/css" href="style.css">
77
<!-- Vue -->
8-
<script src="../../dist/vue.js"></script>
8+
<!-- Delete ".min" for console warnings in development -->
9+
<script src="../../dist/vue.min.js"></script>
910
<!-- Firebase -->
1011
<script src="https://www.gstatic.com/firebasejs/3.4.0/firebase.js"></script>
1112
<!-- VueFire -->

Diff for: examples/grid/index.html

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
<meta charset="utf-8">
55
<title>Vue.js grid component example</title>
66
<link rel="stylesheet" href="style.css">
7-
<script src="../../dist/vue.js"></script>
7+
<!-- Delete ".min" for console warnings in development -->
8+
<script src="../../dist/vue.min.js"></script>
89
</head>
910
<body>
1011

1112
<!-- component template -->
1213
<script type="text/x-template" id="grid-template">
13-
<table>
14+
<table v-if="filteredData.length">
1415
<thead>
1516
<tr>
1617
<th v-for="key in columns"
@@ -30,6 +31,7 @@
3031
</tr>
3132
</tbody>
3233
</table>
34+
<p v-else>No matches found.</p>
3335
</script>
3436

3537
<!-- demo root element -->

Diff for: examples/markdown/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
<link rel="stylesheet" href="style.css">
77
<script src="https://unpkg.com/[email protected]"></script>
88
<script src="https://unpkg.com/[email protected]"></script>
9-
<script src="../../dist/vue.js"></script>
9+
<!-- Delete ".min" for console warnings in development -->
10+
<script src="../../dist/vue.min.js"></script>
1011
</head>
1112
<body>
1213

Diff for: examples/modal/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<head>
44
<meta charset="utf-8">
55
<title>Vue.js Modal Example</title>
6-
<script src="../../dist/vue.js"></script>
6+
<!-- Delete ".min" for console warnings in development -->
7+
<script src="../../dist/vue.min.js"></script>
78
<link rel="stylesheet" href="style.css">
89
</head>
910
<body>

Diff for: examples/move-animations/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
}
3030
</style>
3131
<script src="https://cdn.jsdelivr.net/lodash/4.3.0/lodash.min.js"></script>
32-
<script src="../../dist/vue.js"></script>
32+
<!-- Delete ".min" for console warnings in development -->
33+
<script src="../../dist/vue.min.js"></script>
3334
</head>
3435
<body>
3536
<div id="el">

Diff for: examples/select2/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<head>
44
<meta charset="utf-8">
55
<title>Vue.js custom directive integration example (select2)</title>
6-
<script src="../../dist/vue.js"></script>
6+
<!-- Delete ".min" for console warnings in development -->
7+
<script src="../../dist/vue.min.js"></script>
78
<script src="https://unpkg.com/jquery"></script>
89
<script src="https://unpkg.com/[email protected]"></script>
910
<link href="https://unpkg.com/[email protected]/dist/css/select2.min.css" rel="stylesheet">

Diff for: examples/svg/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
<meta charset="utf-8">
55
<title>Vue.js SVG example</title>
66
<link rel="stylesheet" href="style.css">
7-
<script src="../../dist/vue.js"></script>
7+
<!-- Delete ".min" for console warnings in development -->
8+
<script src="../../dist/vue.min.js"></script>
89
</head>
910
<body>
1011

Diff for: examples/todomvc/index.html

+65-64
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,69 @@
11
<!doctype html>
22
<html data-framework="vue">
3-
<head>
4-
<meta charset="utf-8">
5-
<title>Vue.js • TodoMVC</title>
6-
<link rel="stylesheet" href="https://unpkg.com/todomvc-app-css/index.css">
7-
<script src="https:unpkg.com/director/build/director.js"></script>
8-
<style>[v-cloak] { display: none; }</style>
9-
</head>
10-
<body>
11-
<section class="todoapp">
12-
<header class="header">
13-
<h1>todos</h1>
14-
<input class="new-todo"
15-
autofocus autocomplete="off"
16-
placeholder="What needs to be done?"
17-
v-model="newTodo"
18-
@keyup.enter="addTodo">
19-
</header>
20-
<section class="main" v-show="todos.length" v-cloak>
21-
<input class="toggle-all" type="checkbox" v-model="allDone">
22-
<ul class="todo-list">
23-
<li v-for="todo in filteredTodos"
24-
class="todo"
25-
:key="todo.id"
26-
:class="{ completed: todo.completed, editing: todo == editedTodo }">
27-
<div class="view">
28-
<input class="toggle" type="checkbox" v-model="todo.completed">
29-
<label @dblclick="editTodo(todo)">{{ todo.title }}</label>
30-
<button class="destroy" @click="removeTodo(todo)"></button>
31-
</div>
32-
<input class="edit" type="text"
33-
v-model="todo.title"
34-
v-todo-focus="todo == editedTodo"
35-
@blur="doneEdit(todo)"
36-
@keyup.enter="doneEdit(todo)"
37-
@keyup.esc="cancelEdit(todo)">
38-
</li>
39-
</ul>
40-
</section>
41-
<footer class="footer" v-show="todos.length" v-cloak>
42-
<span class="todo-count">
43-
<strong>{{ remaining }}</strong> {{ remaining | pluralize }} left
44-
</span>
45-
<ul class="filters">
46-
<li><a href="#/all" :class="{ selected: visibility == 'all' }">All</a></li>
47-
<li><a href="#/active" :class="{ selected: visibility == 'active' }">Active</a></li>
48-
<li><a href="#/completed" :class="{ selected: visibility == 'completed' }">Completed</a></li>
49-
</ul>
50-
<button class="clear-completed" @click="removeCompleted" v-show="todos.length > remaining">
51-
Clear completed
52-
</button>
53-
</footer>
54-
</section>
55-
<footer class="info">
56-
<p>Double-click to edit a todo</p>
57-
<p>Written by <a href="http://evanyou.me">Evan You</a></p>
58-
<p>Part of <a href="http://todomvc.com">TodoMVC</a></p>
59-
</footer>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Vue.js • TodoMVC</title>
6+
<link rel="stylesheet" href="https://unpkg.com/todomvc-app-css/index.css">
7+
<script src="https:unpkg.com/director/build/director.js"></script>
8+
<style>[v-cloak] { display: none; }</style>
9+
</head>
10+
<body>
11+
<section class="todoapp">
12+
<header class="header">
13+
<h1>todos</h1>
14+
<input class="new-todo"
15+
autofocus autocomplete="off"
16+
placeholder="What needs to be done?"
17+
v-model="newTodo"
18+
@keyup.enter="addTodo">
19+
</header>
20+
<section class="main" v-show="todos.length" v-cloak>
21+
<input class="toggle-all" type="checkbox" v-model="allDone">
22+
<ul class="todo-list">
23+
<li v-for="todo in filteredTodos"
24+
class="todo"
25+
:key="todo.id"
26+
:class="{ completed: todo.completed, editing: todo == editedTodo }">
27+
<div class="view">
28+
<input class="toggle" type="checkbox" v-model="todo.completed">
29+
<label @dblclick="editTodo(todo)">{{ todo.title }}</label>
30+
<button class="destroy" @click="removeTodo(todo)"></button>
31+
</div>
32+
<input class="edit" type="text"
33+
v-model="todo.title"
34+
v-todo-focus="todo == editedTodo"
35+
@blur="doneEdit(todo)"
36+
@keyup.enter="doneEdit(todo)"
37+
@keyup.esc="cancelEdit(todo)">
38+
</li>
39+
</ul>
40+
</section>
41+
<footer class="footer" v-show="todos.length" v-cloak>
42+
<span class="todo-count">
43+
<strong>{{ remaining }}</strong> {{ remaining | pluralize }} left
44+
</span>
45+
<ul class="filters">
46+
<li><a href="#/all" :class="{ selected: visibility == 'all' }">All</a></li>
47+
<li><a href="#/active" :class="{ selected: visibility == 'active' }">Active</a></li>
48+
<li><a href="#/completed" :class="{ selected: visibility == 'completed' }">Completed</a></li>
49+
</ul>
50+
<button class="clear-completed" @click="removeCompleted" v-show="todos.length > remaining">
51+
Clear completed
52+
</button>
53+
</footer>
54+
</section>
55+
<footer class="info">
56+
<p>Double-click to edit a todo</p>
57+
<p>Written by <a href="http://evanyou.me">Evan You</a></p>
58+
<p>Part of <a href="http://todomvc.com">TodoMVC</a></p>
59+
</footer>
6060

61-
<script>
62-
// for testing
63-
if (navigator.userAgent.indexOf('PhantomJS') > -1) localStorage.clear()
64-
</script>
65-
<script src="../../dist/vue.js"></script>
66-
<script src="app.js"></script>
67-
</body>
61+
<script>
62+
// for testing
63+
if (navigator.userAgent.indexOf('PhantomJS') > -1) localStorage.clear()
64+
</script>
65+
<!-- Delete ".min" for console warnings in development -->
66+
<script src="../../dist/vue.min.js"></script>
67+
<script src="app.js"></script>
68+
</body>
6869
</html>

Diff for: examples/tree/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
list-style-type: dot;
2121
}
2222
</style>
23-
<script src="../../dist/vue.js"></script>
23+
<!-- Delete ".min" for console warnings in development -->
24+
<script src="../../dist/vue.min.js"></script>
2425
</head>
2526
<body>
2627

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"test": "npm run lint && flow check && npm run test:types && npm run test:cover && npm run test:e2e -- --env phantomjs && npm run test:ssr",
2727
"test:unit": "karma start build/karma.unit.config.js",
2828
"test:cover": "karma start build/karma.cover.config.js",
29-
"test:e2e": "npm run build -- vue.js && node test/e2e/runner.js",
29+
"test:e2e": "npm run build -- vue.min.js && node test/e2e/runner.js",
3030
"test:ssr": "npm run build:ssr && VUE_ENV=server jasmine JASMINE_CONFIG_PATH=test/ssr/jasmine.json",
3131
"test:sauce": "npm run sauce -- 0 && npm run sauce -- 1 && npm run sauce -- 2",
3232
"test:types": "tsc -p ./types/test/tsconfig.json",

Diff for: src/compiler/parser/index.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,16 @@ export function parse (
130130
}
131131

132132
function checkRootConstraints (el) {
133-
if (process.env.NODE_ENV !== 'production') {
133+
if (process.env.NODE_ENV !== 'production' && !warned) {
134134
if (el.tag === 'slot' || el.tag === 'template') {
135+
warned = true
135136
warn(
136137
`Cannot use <${el.tag}> as component root element because it may ` +
137138
'contain multiple nodes:\n' + template
138139
)
139140
}
140141
if (el.attrsMap.hasOwnProperty('v-for')) {
142+
warned = true
141143
warn(
142144
'Cannot use v-for on stateful component root element because ' +
143145
'it renders multiple elements:\n' + template
@@ -150,12 +152,12 @@ export function parse (
150152
if (!root) {
151153
root = element
152154
checkRootConstraints(root)
153-
} else if (process.env.NODE_ENV !== 'production' && !stack.length && !warned) {
155+
} else if (!stack.length) {
154156
// allow 2 root elements with v-if and v-else
155157
if (root.if && element.else) {
156158
checkRootConstraints(element)
157159
root.elseBlock = element
158-
} else {
160+
} else if (process.env.NODE_ENV !== 'production' && !warned) {
159161
warned = true
160162
warn(
161163
`Component template should contain exactly one root element:\n\n${template}`

Diff for: test/e2e/specs/grid.js

+6
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ module.exports = {
8282
{ name: 'Chuck Norris', power: Infinity }
8383
])
8484

85+
browser
86+
.clearValue('input[name="query"]')
87+
.assert.count('p', 0)
88+
.setValue('input[name="query"]', 'stringthatdoesnotexistanywhere')
89+
.assert.count('p', 1)
90+
8591
browser.end()
8692

8793
function assertTable (data) {

0 commit comments

Comments
 (0)