That's not how JavaScript works. the only objects on which obj.nodeType fails are null & undefined. and typeof null === "object" so your check doesn't guard against one of those.
On Mon, Oct 31, 2011 at 3:18 PM, Timothy J. Warren <[email protected]>wrote: > > I think the object type check is slightly better, because a primitive type > would also have to check for the nodeType property, and would then throw an > error than the property is undefined. This way, it tosses out primitive > values before they are pointlessly checked for a "nodeType" property. > > > On Monday, October 31, 2011 11:11:05 AM UTC-4, Jake Verbaten wrote: > >> The typeof context === 'object' is not needed, instead replace it with a >> context != null check >> >> On Mon, Oct 31, 2011 at 2:35 PM, Timothy J. Warren <[email protected]>wrote: >> >>> >>> On Monday, October 31, 2011 9:56:22 AM UTC-4, Jake Verbaten wrote: >>>> >>>> >>>> >>>>>> IE doesn't have those constants defined - you need to use the numeric >>>>>> value. >>>>>> >>>>>> http://stackoverflow.com/**quest****ions/1444650/how-does-**one-** >>>>>> acce**ss-the-node-type-**constants**-in-**ie<http://stackoverflow.com/questions/1444650/how-does-one-access-the-node-type-constants-in-ie> >>>>>> -- >>>>>> >>>>> >>>>> Does this apply to IE 8? Because that's my lowest target version. >>>>> >>>> >>>> IE 8 does not have those constants but you can easily shim >>>> it<https://github.com/Raynos/DOM-shim> alternatively >>>> just use the number 1 >>>> >>> >>> Okay, how does this look? http://dev.timshomepage.net/** >>> kis-js/src/core/core.js<http://dev.timshomepage.net/kis-js/src/core/core.js> >>> >> -- > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/[email protected]/ > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/[email protected]/ > > To unsubscribe from this group, send email to > [email protected] > -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
