Skip to content

Commit

Permalink
chore: optimize warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
tazyong committed Jul 1, 2022
1 parent a10c88e commit f7f97f2
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/console.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
const warn = console.warn
console.warn = function(...data) {
const msg = data[0] || ""
if (msg.startsWith("[Vue warn]: Extraneous non-props attributes (data-v-inspector-file, data-v-inspector-line, data-v-inspector-column, data-v-inspector-title)")) return
console.warn = function (...data) {
const skipMsgPrefix = "[Vue warn]: Extraneous non-props attributes ";
let msg = data[0] || ""
if (msg.startsWith(skipMsgPrefix)) {
msg = msg.replace(/\([^)]+\)/, function (match) {
const attributes = match
.slice(1, -1)
.split(', ')
.filter(function (item) {
return !/^data-v-inspector-(file|line|column|title)$/.test(item)
})
.join(', ')
return '(' + attributes + ')'
})
if (msg.slice(skipMsgPrefix.length).startsWith('()')) return
if (msg) data[0] = msg
}
warn(...data)
}

0 comments on commit f7f97f2

Please sign in to comment.