Commit d2687c2e authored by David Sveningsson's avatar David Sveningsson

fix(dom): use case-insensitive match for `is()`

parent af39ea1d
......@@ -394,6 +394,16 @@ describe("HtmlElement", () => {
expect(el.is("bar")).toBeFalsy();
});
it("should match case-insensitive", () => {
expect.assertions(4);
const a = new HtmlElement("foo");
const b = new HtmlElement("BAR");
expect(a.is("foo")).toBeTruthy();
expect(a.is("FOO")).toBeTruthy();
expect(b.is("bar")).toBeTruthy();
expect(b.is("BAR")).toBeTruthy();
});
it("should match any tag when using asterisk", () => {
const el = new HtmlElement("foo");
expect(el.is("*")).toBeTruthy();
......
......@@ -140,7 +140,12 @@ export class HtmlElement extends DOMNode {
* If passing "*" this test will pass if any tagname is set.
*/
public is(tagName: string): boolean {
return (this.tagName && tagName === "*") || this.tagName === tagName;
if (!this.tagName) {
return false;
}
return (
tagName === "*" || this.tagName.toLowerCase() === tagName.toLowerCase()
);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment