Skip to content

appendTestResults() creates DOM that is invalid HTML if serialised  #1301

@kjax

Description

@kjax

Tell us about your runtime:

  • QUnit version: 2.6.1
  • What environment are you running QUnit in? (e.g., browser, Node): Browser
  • How are you running QUnit? (e.g., script, testem, Grunt): grunt

What are you trying to do?

If the contents of "#qunit" is extracted with innerHTML and written to a HTML file, the resultant HTML is invalid. This is because "#qunit-testresult" is created as a "p" and its innerHTML is filled with several "divs" like "#qunit-testresult-display" and "#qunit-testresult-controls".

The problem is that a "div" element is not valid content of a "p". In fact the HTML spec states that a "p" followed by a "div" should assume that the end tag of the "p" has been omitted.

The result of parsing <p id=qunit-testresult"><div id=qunit-testresult-display /></p> is an empty "p" element with the "divs" as siblings. This breaks any CSS used to format this section.

The fix is to make "#qunit-testresult" a "div" instead.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions