happy-dom
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -63,3 +63,5 @@ "use strict"; | ||
ClassList.prototype.contains = function (className) { | ||
return this.ownerElement.getAttribute('class').includes(className); | ||
var attr = this.ownerElement.getAttribute('class'); | ||
var list = attr ? attr.split(' ') : []; | ||
return list.includes(className); | ||
}; | ||
@@ -66,0 +68,0 @@ return ClassList; |
@@ -43,6 +43,5 @@ "use strict"; | ||
if (this.isClass) { | ||
var className = element.className; | ||
var classRegexp = new RegExp(CLASS_REGEXP, 'g'); | ||
while ((match = classRegexp.exec(part))) { | ||
if (!className || !className.includes(match[1])) { | ||
if (!element.classList.contains(match[1])) { | ||
return false; | ||
@@ -49,0 +48,0 @@ } |
{ | ||
"name": "happy-dom", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/capricorn86/happy-dom#readme", |
@@ -197,2 +197,3 @@ # Happy DOM | ||
| ------- | ---------- | ---------------- | | ||
| 0.4.2 | 2019-10-08 | Fixes issue where query selector not returning correct elements. (#2) | | ||
| 0.4.1 | 2019-10-07 | Fixes issue with self closing elements become parent of next element in HTMLParser. (#1) | | ||
@@ -199,0 +200,0 @@ | 0.4.0 | 2019-10-07 | Adds type and eventInit to Event constructor. (#4) | |
@@ -58,4 +58,6 @@ import Element from '../nodes/basic-types/Element'; | ||
public contains(className: string): boolean { | ||
return this.ownerElement.getAttribute('class').includes(className); | ||
const attr = this.ownerElement.getAttribute('class'); | ||
const list = attr ? attr.split(' ') : []; | ||
return list.includes(className); | ||
} | ||
} |
@@ -21,5 +21,5 @@ import Element from '../nodes/basic-types/Element'; | ||
for(const part of selector.split(',')) { | ||
for (const part of selector.split(',')) { | ||
const foundElements = this.singleQuerySelectorAll(node, part.trim()); | ||
if(foundElements) { | ||
if (foundElements) { | ||
matched = matched.concat(foundElements); | ||
@@ -40,5 +40,5 @@ } | ||
public static querySelector(node: Node, selector: string): Element { | ||
for(const part of selector.split(',')) { | ||
for (const part of selector.split(',')) { | ||
const foundElement = this.singleQuerySelector(node, part.trim()); | ||
if(foundElement) { | ||
if (foundElement) { | ||
return foundElement; | ||
@@ -45,0 +45,0 @@ } |
@@ -56,9 +56,8 @@ import Element from '../nodes/basic-types/Element'; | ||
if (this.isClass) { | ||
const className = element.className; | ||
const classRegexp = new RegExp(CLASS_REGEXP, 'g'); | ||
while ((match = classRegexp.exec(part))) { | ||
if (!className || !className.includes(match[1])) { | ||
return false; | ||
} | ||
if (!element.classList.contains(match[1])) { | ||
return false; | ||
} | ||
} | ||
@@ -65,0 +64,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
550378
13921
235