-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(engine): clean up error messages #1193
Changes from 21 commits
697cc77
01689a6
37a32f6
89234d8
efef8d5
f677bd9
e81a86d
b4d3411
b2146b0
c749398
97e0da9
a8e0664
9f83c19
598c7b4
db4983a
764fd61
8fdfcc2
de16257
9cae359
042f838
e21fd2d
7ff440a
5b581fb
248e74a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -270,8 +270,8 @@ export function h(sel: string, data: ElementCompilerData, children: VNodes): VEl | |
`vnode.data.styleMap and vnode.data.style ambiguous declaration.` | ||
); | ||
if (data.style && !isString(data.style)) { | ||
assert.logWarning( | ||
`Invalid 'style' attribute passed to <${sel}> should be a string value, and will be ignored.`, | ||
assert.logError( | ||
`Invalid 'style' attribute passed to <${sel}> is ignored. This attribute must be a string value.`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should keep this error (which used to be a warning) |
||
vmBeingRendered!.elm | ||
); | ||
} | ||
|
@@ -321,10 +321,10 @@ export function ti(value: any): number { | |
const shouldNormalize = value > 0 && !(isTrue(value) || isFalse(value)); | ||
if (process.env.NODE_ENV !== 'production') { | ||
if (shouldNormalize) { | ||
assert.logWarning( | ||
assert.logError( | ||
`Invalid tabindex value \`${toString( | ||
value | ||
)}\` in template for ${vmBeingRendered}. This attribute can only be set to 0 or -1.`, | ||
)}\` in template for ${vmBeingRendered}. This attribute must be set to 0 or -1.`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should keep this error (which used to be a warning) |
||
vmBeingRendered!.elm | ||
); | ||
} | ||
|
@@ -392,8 +392,8 @@ export function c( | |
`vnode.data.styleMap and vnode.data.style ambiguous declaration.` | ||
); | ||
if (data.style && !isString(data.style)) { | ||
assert.logWarning( | ||
`Invalid 'style' attribute passed to <${sel}> should be a string value, and will be ignored.`, | ||
assert.logError( | ||
`Invalid 'style' attribute passed to <${sel}> is ignored. This attribute must be a string value.`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should keep this error (which used to be a warning) |
||
vmBeingRendered!.elm | ||
); | ||
} | ||
|
@@ -444,10 +444,10 @@ export function i( | |
markAsDynamicChildren(list); | ||
if (isUndefined(iterable) || iterable === null) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
assert.logWarning( | ||
assert.logError( | ||
`Invalid template iteration for value "${toString( | ||
iterable | ||
)}" in ${vmBeingRendered}, it should be an Array or an iterable Object.`, | ||
)}" in ${vmBeingRendered}. It must be an Array or an iterable Object.`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should keep this error (which used to be a warning) |
||
vmBeingRendered!.elm | ||
); | ||
} | ||
|
@@ -459,7 +459,7 @@ export function i( | |
isUndefined(iterable[SymbolIterator]), | ||
`Invalid template iteration for value \`${toString( | ||
iterable | ||
)}\` in ${vmBeingRendered}, it requires an array-like object, not \`null\` or \`undefined\`.` | ||
)}\` in ${vmBeingRendered}. It must be an array-like object and not \`null\` nor \`undefined\`.` | ||
); | ||
} | ||
const iterator = iterable[SymbolIterator](); | ||
|
@@ -502,15 +502,15 @@ export function i( | |
if (keyMap[key] === 1 && isUndefined(iterationError)) { | ||
iterationError = `Duplicated "key" attribute value for "<${ | ||
childVnode.sel | ||
}>" in ${vmBeingRendered} for item number ${j}. Key with value "${ | ||
}>" in ${vmBeingRendered} for item number ${j}. A key with value "${ | ||
childVnode.key | ||
}" appears more than once in iteration. Key values must be unique numbers or strings.`; | ||
}" appears more than once in the iteration. Key values must be unique numbers or strings.`; | ||
} | ||
keyMap[key] = 1; | ||
} else if (isUndefined(iterationError)) { | ||
iterationError = `Invalid "key" attribute value in "<${ | ||
childVnode.sel | ||
}>" in ${vmBeingRendered} for item number ${j}. Instead set a unique "key" attribute value on all iteration children so internal state can be preserved during rehydration.`; | ||
}>" in ${vmBeingRendered} for item number ${j}. Set a unique "key" value on all iterated child elements.`; | ||
} | ||
} | ||
}); | ||
|
@@ -681,7 +681,7 @@ export function gid(id: string | undefined | null): string | null | undefined { | |
if (isUndefined(id) || id === '') { | ||
if (process.env.NODE_ENV !== 'production') { | ||
assert.logError( | ||
`Invalid id value "${id}". Expected a non-empty string.`, | ||
`Invalid id value "${id}". The id attribute must contain a non-empty string.`, | ||
vmBeingRendered!.elm | ||
); | ||
} | ||
|
@@ -698,10 +698,12 @@ export function gid(id: string | undefined | null): string | null | undefined { | |
export function fid(url: string | undefined | null): string | null | undefined { | ||
if (isUndefined(url) || url === '') { | ||
if (process.env.NODE_ENV !== 'production') { | ||
assert.logError( | ||
`Invalid url value "${url}". Expected a non-empty string.`, | ||
vmBeingRendered!.elm | ||
); | ||
if (isUndefined(url)) { | ||
assert.logError( | ||
`Undefined url value for "href" or "xlink:href" attribute. Expected a non-empty string.`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should keep this error but relax it so that it only cares about |
||
vmBeingRendered!.elm | ||
); | ||
} | ||
} | ||
return url; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you think of 'parent' instead of 'owner'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the second note, should we point the user to the lifecycle hook during the invocation of which the owner has already set the values? Such as connected callback?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apapko I think suggesting a different lifecycle hook might be assuming too much since we don't know what the developer is trying to do. They might have some logic which doesn't care about whether the value is the initialized value or the owner-provided value.
The error message does seem a little weird though since it looks like it'll get logged even for
@caridy Seems like another candidate for removal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For posterity, we discussed this and agreed it should be removed since we can't predict the author's intention.