Node.TEXT_NODE and IE7
Asked Answered
O

1

14

I've some javascript that tests DOM node types against like this:

        if(node.nodeType == Node.TEXT_NODE) {

Of course, it all works fine in Firefox, Safari, and Opera. But Internet Explorer 7 is complaining that Node (with the capital N) is undefined. But that's part of DOM Level 2!

Do I really need to change my code to use magic numbers? Or am I missing something simple here?

Omniscience answered 14/9, 2009 at 19:59 Comment(0)
T
18

Unfortunately you are not missing anything.

There is no Node constant in IE. Look here http://www.ibm.com/developerworks/xml/library/x-matters41.html at section "What else can you do with the DOM?".

So either you define your own Node constant or you simply ask for

node.nodeType === 3
Thermostatics answered 28/9, 2009 at 14:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.