Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix tests for existing elements #311

Merged
merged 1 commit into from

2 participants

@lucianafujii

The type of a just created HTMLElement is never undefined, it is
actually an object of type HTMLUnknownElement. So now instead of
comparing to undefined, the tests check if the element is an instance of
HTMLUnknownElement and fails if it is.

@lucianafujii lucianafujii Fix tests for existing elements
The type of a just created HTMLElement is never undefined, it is
actually an object of type HTMLUnknownElement. So now instead of
comparing to undefined, the tests check if the element is an instance of
HTMLUnknownElement and fails if it is.
00163d9
@NielsLeenheer

You are right that there should be an extra check for instanceof HTMLUnknownElement. On browsers that follow HTML5 tree creation algorithm unknown elements are and instance of HTMLUnknownElement which is a descendant of HTMLElement. Just checking for instanceof HTMLElement will always pass.

On older browsers this does work because before the adoption of the HTML5 unknown elements were not an descendant of HTMLElement.

The check for typeof HTMLElement != 'undefined' was there originally for a reason. Not all browsers have a generic HTMLElement defined. Of course modern browsers do, but if you run the test on I think S60 or S40 Webkit instanceof HTMLElement gives an error. That error is now also handled by the try {} catch() {}, so it could indeed be removed.

I think the patch is good as-is. But before landing I want to check if it works as expected on older devices.

@NielsLeenheer NielsLeenheer merged commit dffbfd8 into NielsLeenheer:version-5.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 20, 2013
  1. @lucianafujii

    Fix tests for existing elements

    lucianafujii authored
    The type of a just created HTMLElement is never undefined, it is
    actually an object of type HTMLUnknownElement. So now instead of
    comparing to undefined, the tests check if the element is an instance of
    HTMLUnknownElement and fails if it is.
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 8 deletions.
  1. +8 −8 scripts/engine.js
View
16 scripts/engine.js
@@ -1176,7 +1176,7 @@ Test = (function() {
var passed = false;
try {
- passed = typeof HTMLElement != 'undefined' && element instanceof HTMLElement && this.isBlock(element) && this.closesImplicitly(elements[e]);
+ passed = element instanceof HTMLElement && !(element instanceof HTMLUnknownElement) && this.isBlock(element) && this.closesImplicitly(elements[e]);
} catch(error) {
}
@@ -1201,7 +1201,7 @@ Test = (function() {
var passed = false;
try {
- passed = typeof HTMLElement != 'undefined' && element instanceof HTMLElement && this.isBlock(element) && (elements[e] != 'figure' || this.closesImplicitly(elements[e]));
+ passed = element instanceof HTMLElement && !(element instanceof HTMLUnknownElement) && this.isBlock(element) && (elements[e] != 'figure' || this.closesImplicitly(elements[e]));
} catch(error) {
}
@@ -1245,7 +1245,7 @@ Test = (function() {
var passed = false;
try {
- passed = typeof HTMLElement != 'undefined' && element instanceof HTMLElement && (color = this.getStyle(element, 'background-color')) && (color != 'transparent');
+ passed = element instanceof HTMLElement && !(element instanceof HTMLUnknownElement) && (color = this.getStyle(element, 'background-color')) && (color != 'transparent');
} catch(error) {
}
@@ -1269,9 +1269,9 @@ Test = (function() {
var rpSupport = false;
try {
- rubySupport = rubyElement && typeof HTMLElement != 'undefined' && rubyElement instanceof HTMLElement;
- rtSupport = rtElement && typeof HTMLElement != 'undefined' && rtElement instanceof HTMLElement;
- rpSupport = rpElement && typeof HTMLElement != 'undefined' && rpElement instanceof HTMLElement && this.isHidden(rpElement);
+ rubySupport = rubyElement && rubyElement instanceof HTMLElement && !(element instanceof HTMLUnknownElement);
+ rtSupport = rtElement && rtElement instanceof HTMLElement && !(element instanceof HTMLUnknownElement);
+ rpSupport = rpElement && rpElement instanceof HTMLElement && !(element instanceof HTMLUnknownElement) && this.isHidden(rpElement);
} catch(error) {
}
@@ -1301,7 +1301,7 @@ Test = (function() {
var passed = false;
try {
- passed = typeof HTMLElement != 'undefined' && element instanceof HTMLElement;
+ passed = element instanceof HTMLElement && !(element instanceof HTMLUnknownElement);
} catch(error) {
}
@@ -1335,7 +1335,7 @@ Test = (function() {
var passed = false;
try {
- passed = typeof HTMLElement != 'undefined' && element instanceof HTMLElement;
+ passed = element instanceof HTMLElement && !(element instanceof HTMLUnknownElement);
} catch(error) {
}
Something went wrong with that request. Please try again.