-
Notifications
You must be signed in to change notification settings - Fork 27.5k
jqLite('<div>') throws an error in an XHTML document #6917
Comments
Works for me in devtools, even by setting innerHTML to invalid markup as you suggested, in an XHTML document. $0.ownerDocument.doctype
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
$0.innerHTML
"<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>circles</title>
</head>
<body>
<object height="350" width="600" type="image/svg+xml" data="circles.svg"/>
</body>
</html>
"
$0.innerHTML = '<div>'
"<div>"
$0.innerHTML
"<div></div>"
$0.innerHTML = "<div> </div><div>Hello, world!"
"<div> </div><div>Hello, world!"
$0.innerHTML
"<div> </div><div>Hello, world!</div>" I'll have to test it with a proper test obviously, but in any case, just include the closing tag in your template? |
Ah, I didn't think it was specific to XHTML5 (what I'm using). Here's a minimal file (serve with Content-Type: application/xhtml+xml) <?xml version="1.0" encoding="utf-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head/>
<body/>
</html> (Notice no doctype, only the XML header, as is allowed by XHTML5). You will see the error now. > document.body.innerHTML = "<div>"
SyntaxError: Failed to set the 'innerHTML' property on 'Element': The provided markup is invalid XML, and therefore cannot be inserted into an XML document.
It has nothing to do with my template (and in fact my template is well formed). The line that inserts only the opening tag is in angular's source. It's the very first thing I've linked in the OP. |
What I mean is, There is no code in the JQLite constructor where |
Again, it is the first thing I've linked in the OP. The call to |
Feel free to send a patch to add a closing tag to that call. What I'm saying is that this is not really a bug with jqLite |
FYI, I don't know whether you want parity with |
making jqLite as robust as jQuery is not really in the cards, jQuery is huge and has people actually working on it and maintaining it, while jqLite is just the minimal that is needed for angular to work. Getting feature-parity with jQuery is not going to happen |
All right, then as you said, this can be considered a bug in all places in Angular that call jqLite with just a starting tag, and not in jqLite itself. One such place is the one I've opened this bug about; I didn't look for more. |
I don't think you'll find very many of these, the compiler is wrapping everything correctly when it manipulates templates on its own |
Well, I just grepped for
My grep wouldn't have found any calls to jqLite that don't pass in a literal string, and just grepping for jqLite finds many more results than I care to investigate... |
These are in unit tests, they aren't going to affect the runtime. |
This one. There are a few in test/jqLiteSpec.js as well.
For example, the error on Chrome is
Error: Failed to set the 'innerHTML' property on 'Element': The provided markup is invalid XML, and therefore cannot be inserted into an XML document.
The reason is that the implementation of jqLite tries to set innerHTML to that argument on this line
div.innerHTML = '<div> </div>' + element;
(where element is'<div>'
) and this is malformed without a closing</div>
at the end.It is trivial to test: just call
jqLite('<div>')
and see if it throws the above error.I found this issue with its associated commit that seems to indicate the author knew about this problem but I suppose they didn't actually test it in XHTML.
The text was updated successfully, but these errors were encountered: