Skip to main content

Bug Tracker

Side navigation

#12086 closed bug (invalid)

Opened July 16, 2012 11:14AM UTC

Closed July 17, 2012 12:40PM UTC

Checking value for null after using property of value. Method "attr"

Reported by: deltaplans@mail.ru Owned by: deltaplans@mail.ru
Priority: low Milestone: None
Component: attributes Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:
Description

Checking value for null after using property of value.

There is next code (start from 2511 row) in current version (source code, but in min version code is same):

 attr: function( elem, name, value, pass ) {
                var ret, hooks, notxml,
                  nType = elem.nodeType;

		// don't get/set attributes on text, comment and attribute nodes
		if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
			return;
		}

For getting nType value used elem.nodeType, but elem didn't check for null before. It will checked after that (in the next rows). It seems that it should be lik this:



if ( !elem) return;

var ret, hooks, notxml,
                  nType = elem.nodeType;
 if(nType === 3 || nType === 8 || nType === 2 ) {
			return;
		}

Attachments (0)
Change History (5)

Changed July 16, 2012 12:04PM UTC by dmethvin comment:1

owner: → deltaplans@mail.ru
status: newpending

What code is this affecting? Since null is not an element it shouldn't be passed there.

Changed July 16, 2012 12:15PM UTC by anonymous comment:2

ok, just I use jqGrid and it call this method with null value.

I looked to version 1.5.2 and this have checking for null or undefined first here.

But anyway maybe it is right to do checking elem, and than get his property?

Changed July 16, 2012 02:31PM UTC by addyosmani comment:3

component: unfiledattributes
priority: undecidedlow

null shouldn't be getting passed as an element reference to attr() and if jqGrid is doing this then they should be updating their code to perform checks on the input being passed through through the chain. imo, the current behavior shouldn't change. Garbage in, garbage out :)

Changed July 17, 2012 05:47AM UTC by deltaplan comment:4

ok, thank you

Changed July 17, 2012 12:40PM UTC by mikesherov comment:5

resolution: → invalid
status: pendingclosed