On 11/6/21 2:46 PM, Gabriel Ivăncescu wrote:
I thought of another idea, which I don't think is necessarily better, but maybe it's worth a thought.
We could iterate through a bunch of root context tags, namely <template>, <head> and <html> in that order, then use setInnerHTML on them and retrieve the first child, until we get a child and then use that if we did.
I guess <html> context might be tricky here, since it can be either
<head> or <body> tag that is parsed, might need some special casing (and retrieve either first or second child in such case, perhaps we can just check the first letter since other tags should already work in either <template> or <head> themselves—so would have been filtered already).
Just an idea. Is it worth pursuing?
The whole thing is still too hacky, in my opinion. If we can't get Gecko to do what we need, maybe we need to do parsing ourselves. Given that we only need to parse a small subset of HTML, it shouldn't be too bad and all we need from Gecko is createElement() and setAttribute().
Thanks,
Jacek