Skip to content

Commit f623eee

Browse files
committed
validate template
1 parent 7dab160 commit f623eee

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

lib/loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ module.exports = function (content) {
135135
}
136136
}
137137

138-
var parts = parse(content, fileName)
138+
var parts = parse(content, fileName, this.emitWarning)
139139
var hasLocalStyles = false
140140
var output = 'var __vue_script__, __vue_template__\n'
141141

lib/parser.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
var parse5 = require('parse5')
2+
var validateTemplate = require('vue-template-validator')
23
var cache = require('lru-cache')(100)
34
var SourceMapGenerator = require('source-map').SourceMapGenerator
45
var hash = require('hash-sum')
56
var deindent = require('de-indent')
67
var splitRE = /\r?\n/g
78
var emptyRE = /^\s*$/
89

9-
module.exports = function (content, filename) {
10+
module.exports = function (content, filename, warn) {
1011

1112
var cacheKey = hash(filename + content)
1213
// source-map cache busting for hot-reloadded modules
@@ -76,6 +77,9 @@ module.exports = function (content, filename) {
7677
// template content is nested inside the content fragment
7778
if (type === 'template') {
7879
node = node.content
80+
if (!lang) {
81+
validateTemplate(node, content, warn)
82+
}
7983
}
8084

8185
// extract part

lib/selector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = function (content) {
66
this.cacheable()
77
var query = loaderUtils.parseQuery(this.query)
88
var filename = path.basename(this.resourcePath)
9-
var parts = parse(content, filename)
9+
var parts = parse(content, filename, this.emitWarning)
1010
var part = parts[query.type][query.index]
1111
this.callback(null, part.content, part.map)
1212
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
"parse5": "^2.0.2",
3939
"postcss": "^5.0.10",
4040
"postcss-selector-parser": "^1.1.2",
41-
"source-map": "^0.5.3"
41+
"source-map": "^0.5.3",
42+
"vue-template-validator": "^1.0.0"
4243
},
4344
"peerDependencies": {
4445
"vue-html-loader": "^1.0.0",

0 commit comments

Comments
 (0)