Better detection of DOM Nodes for equality

- Also use JSDom if a real one isn't present to get some more coverage
  there

- Fixes #1172
This commit is contained in:
Gregg Van Hove
2018-05-04 18:01:08 -07:00
parent f7097281c9
commit ced2b114e4
5 changed files with 75 additions and 37 deletions

View File

@@ -233,8 +233,8 @@ getJasmineRequireObj().pp = function(j$) {
if (el.innerHTML === '') {
this.append(el.outerHTML.replace(closingTag, ''));
} else {
var tagEnd = el.outerHTML.indexOf(el.innerHTML);
this.append(el.outerHTML.substring(0, tagEnd));
var tagEnd = el.outerHTML.indexOf('>');
this.append(el.outerHTML.substring(0, tagEnd + 1));
this.append('...' + closingTag);
}
};

View File

@@ -101,7 +101,14 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
};
j$.isDomNode = function(obj) {
return obj.nodeType > 0;
// Node is a function, because constructors
return typeof jasmineGlobal.Node !== 'undefined' ?
obj instanceof jasmineGlobal.Node :
obj !== null &&
typeof obj === 'object' &&
typeof obj.nodeType === 'number' &&
typeof obj.nodeName === 'string';
// return obj.nodeType > 0;
};
j$.isMap = function(obj) {