Closed cortopy closed 4 years ago
In: xml('<text>').filter(...)
. the filter method is the native filter of an array. It only can find head
and body
here.
I was mostly using the filter the following way:
const elements = xml(`<head>
<style>
p { color: "red" }
</style>
</head>
<body>
<p>hello</p>
</body>`);
xml.filter(elements, element => {
return element.tagName.toLowerCase() == 'style';
});
Thanks for sharing this experience ! ! I will definitely fix the type definition and see how I can improve the documentation around this.
thank you!
I'm a bit confused about how to use the utility methods and I'm getting inconsistent outputs.
With the following HTML string
I get different results depending on how I use
filter
.Following the README and the typescript types this example seems to be the correct one:
However, it returns an empty array.
After digging into the unit tests, it appears that using
filter
as an option renders the desire output.But this feels weird because it's not documented (I don't know if it will break in certain circumstances) and the typescript types don't reflect it