What about removing whitespaces from both sides of strings in the condition of 'getElementsContainingText' helper ?
By changing it with something like this:
if (elements[i][txtProp].trim() === content.trim()) {
results.push(elements[i]);
}
The problem I encounter is that HTML tags had not the same innerText and textContent string values and both could contained (not the same) leading and trailing whitespace(s) and carriage return(s).
So, If I want to search "Hello" in these examples, currently only the first will work all the time:
What about removing whitespaces from both sides of strings in the condition of 'getElementsContainingText' helper ?
By changing it with something like this:
The problem I encounter is that HTML tags had not the same innerText and textContent string values and both could contained (not the same) leading and trailing whitespace(s) and carriage return(s).
So, If I want to search "Hello" in these examples, currently only the first will work all the time:
As a workaround, I copy-paste the getElementsContainingText content function in my test code with the fix above.