Html::closeElement: Don't omit closing tags.
Although it's allowed by the HTML Living Standard in particular circumstances, the rules are non-trivial and can not be enforced by this method since it has no context. For example, as of http://web.archive.org/web/20140807160955/http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html#optional-tags it says: "A head element's end tag may be omitted if the head element is not immediately followed by a space character or a comment." Html::closeElement has no way of knowing whether there is a space character or comment after the tag. There are similar issues with some other tags (e.g. body). Also, even when the rule should be followed anyway (e.g. lists can only contain li elements), there is evidence of browser issues (bug 52210). Use closing tags for all elements for simplicity. Bug: 52210 Change-Id: I97ce415288300e40c4d0aa0442bdf4ee3dedb30f
This commit is contained in:
parent
e054e34af8
commit
d950da075d
1 changed files with 0 additions and 17 deletions
|
|
@ -233,25 +233,8 @@ class Html {
|
|||
* @return string A closing tag, if required
|
||||
*/
|
||||
public static function closeElement( $element ) {
|
||||
global $wgWellFormedXml;
|
||||
|
||||
$element = strtolower( $element );
|
||||
|
||||
// Reference:
|
||||
// http://www.whatwg.org/html/syntax.html#optional-tags
|
||||
if ( !$wgWellFormedXml && in_array( $element, array(
|
||||
'html',
|
||||
'head',
|
||||
'body',
|
||||
'li',
|
||||
'dt',
|
||||
'dd',
|
||||
'tr',
|
||||
'td',
|
||||
'th',
|
||||
) ) ) {
|
||||
return '';
|
||||
}
|
||||
return "</$element>";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue