Created
December 22, 2020 15:04
-
-
Save MustSeeMelons/7a94f4b756d1ee56d648e1fc0aeba073 to your computer and use it in GitHub Desktop.
Show The Logs Harold - Element content search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
useEffect(() => { | |
const children = jsonRef.current.getElementsByTagName("*"); | |
const childArray = [].slice.call(children) as HTMLElement[]; | |
const filterElements: HTMLElement[] = []; | |
childArray.forEach((el) => { | |
if ( | |
el.textContent && | |
el.textContent.includes(props.filterValue) && | |
el.children.length === 0 && | |
props.currentFilteredJson | |
) { | |
filterElements.push(el); | |
el.style.backgroundColor = props.theme.colors.primary.accentText; | |
el.style.color = props.theme.colors.primary.lightText; | |
} else { | |
el.style.backgroundColor = "inherit"; | |
el.style.color = "inherit"; | |
} | |
}); | |
props.setFilterElements(filterElements); | |
}, [props.currentFilteredJson, jsonRef, props.isUiLocked]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment