Details
-
Type: Improvement
-
Status: Closed
-
Priority: Major
-
Resolution: Duplicate
-
Affects Version/s: 1.5, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.6DR#1, 1.6DR#2, 1.6DR#3, 1.6DR#4, 1.6DR#5, 1.6DR#6, 1.6, 1.6.1, 1.6.2, 1.6.3, 1.7DR#1, 1.7DR#2, 1.7DR#3, 1.7, 2.0-Alpha3
-
Fix Version/s: 1.7
-
Component/s: Framework
-
Labels:None
-
Environment:All
Description
in com.icesoft.core.faces.util.DOMUtils
change lines
/*
if ( !node.hasChildNodes() )
{
stringbuffer.append(" />\n");
break;
}
*/
to
if ( !node.hasChildNodes() && xmlShortClosingAllowed(node) )
{
stringbuffer.append(" />");
break;
}
notice the removed \n ? It's because text nodes already have needed \n in them and therefore additional \n ends up breaking things rather than making anything look better
and add such function
private static boolean xmlShortClosingAllowed(Node node) {
String tags = "img, input, br, meta, base, link";
short nodeType = node.getNodeType();
String nodeName = node.getNodeName().toLowerCase();
return (nodeType == Node.ELEMENT_NODE && tags.indexOf(nodeName) > -1);
}
and remove
if (name.equalsIgnoreCase("br")) {
stringbuffer.append("<br />");
break;
}
because now xml short tag support is ok, meaning br tag will be outputted as <br /> correctly plus, since <br /> can have attribute clear ( <br clear="both" /> for example), that attribute gets now rendered too
Just uncommenting those first lines ended in errors because there are some tags that can ONLY exist with ending tags, so it's better to allow only specific know tags end with /> when they have no children (the list may be bigger but those are the ones I came up with)
I wonder how come no one else has bothered to check the outputted html correctenss before :D
Any how, I hope those fixes get into 1.7DR#3 and possibly backported to other releases too since as far as I know, IE6(the biggest troublechild) already has correct XML support and can read <br /> tags correctly so there should be no reasons not to implement this.
change lines
/*
if ( !node.hasChildNodes() )
{
stringbuffer.append(" />\n");
break;
}
*/
to
if ( !node.hasChildNodes() && xmlShortClosingAllowed(node) )
{
stringbuffer.append(" />");
break;
}
notice the removed \n ? It's because text nodes already have needed \n in them and therefore additional \n ends up breaking things rather than making anything look better
and add such function
private static boolean xmlShortClosingAllowed(Node node) {
String tags = "img, input, br, meta, base, link";
short nodeType = node.getNodeType();
String nodeName = node.getNodeName().toLowerCase();
return (nodeType == Node.ELEMENT_NODE && tags.indexOf(nodeName) > -1);
}
and remove
if (name.equalsIgnoreCase("br")) {
stringbuffer.append("<br />");
break;
}
because now xml short tag support is ok, meaning br tag will be outputted as <br /> correctly plus, since <br /> can have attribute clear ( <br clear="both" /> for example), that attribute gets now rendered too
Just uncommenting those first lines ended in errors because there are some tags that can ONLY exist with ending tags, so it's better to allow only specific know tags end with /> when they have no children (the list may be bigger but those are the ones I came up with)
I wonder how come no one else has bothered to check the outputted html correctenss before :D
Any how, I hope those fixes get into 1.7DR#3 and possibly backported to other releases too since as far as I know, IE6(the biggest troublechild) already has correct XML support and can read <br /> tags correctly so there should be no reasons not to implement this.
Issue Links
- depends on
-
ICE-2393 XHTML: standard JSF components, <img> should be self-closed
- Closed
Activity
Indrek Altpere
created issue -
Ken Fyten
made changes -
Status | Open [ 1 ] | Closed [ 6 ] |
Fix Version/s | 1.7 [ 10080 ] | |
Resolution | Duplicate [ 3 ] |
Duplicate of existing JIRA.