fix(react): checking if node is actually an element before treating it like one, fixes #19769 (#19783)

This commit is contained in:
Ely Lucas
2019-10-29 10:36:28 -06:00
parent 1f2b161ccd
commit e23d91c6e7

View File

@ -1,6 +1,8 @@
import { camelToDashCase } from './case';
export const attachProps = (node: HTMLElement, newProps: any, oldProps: any = {}) => {
// some test frameworks don't render DOM elements, so we test here to make sure we are dealing with DOM first
if (node instanceof Element) {
// add any classes in className to the class list
const className = getClassName(node.classList, newProps, oldProps);
if (className !== '') {
@ -28,6 +30,7 @@ export const attachProps = (node: HTMLElement, newProps: any, oldProps: any = {}
}
}
});
}
};
export const getClassName = (classList: DOMTokenList, newProps: any, oldProps: any) => {