el.querySelectorAll() is not a function (on comment nodes)
cb-fred opened this issue · 11 comments
Hi,
Aurelia-i18n 0.5.3 throws an exception in the updateTranslations(el) (i18n.js:136) function if it is called with a comment node as a parameter, as querySelectorAll() is not defined on comment nodes (at least in the latest chrome)
I guess the fix would be simply to ignore comment nodes, by checking (el.nodeType !== 8)
@zewa666 Ping.
I see that the latest wave of update of yesterday for the RC of Aurelia didn't update aurelia-i18n, any news on a fix for this bug and hopefully some more fix to be released soon?
@zewa666 is on vacation. Everyone needs a rest :) He'll be looking into these issues when he returns, which shouldn't be much longer.
Pull Requests are welcome as always.
I just founded that somehow, comments nodes are passed through the function. Since a comment tag in HTML didn't have any property, hence, it doesn't have a querySelectorAll function neither. I made a quick fix to skip those nodes on my local copy but I'm not sure this is the best nor the real solution beside I think it doesn't make sense to parse those comment, except if we can use them to output some translations.
My fix consist of adding this at the beginning of the updateTranslations function
if (el.nodeType === Node.COMMENT_NODE) { return }
To me its a pretty shady looking fix and there should be a better solution. What you think, are comment nodeType should be processed through that function?
@maroy1986 and @cb-fred thanks for pointing out the issue. Actually more checks are needed for stuff like undefined elements or text-nodes as such I've fixed up the updateTranslations method a bit. Should be available in the upcoming release
Thanks @zewa666! I have to admit that was easy and more straight forward than I thought to fix after looking to your commit :)
@maroy1986 and @cb-fred the new release is published, please check out whether it fixes your issue
I confirm it fix my issue. Everything's good now! Thanks!
Great, going to close this, thanks for checking back