Opened 7 years ago

Closed 6 years ago

Last modified 6 years ago

#16514 closed defect (fixed)

Form: set("value", val) broken if val contains array from another frame

Reported by: bill Owned by: Douglas Hays
Priority: undecided Milestone: 1.9
Component: Dijit - Form Version: 1.8.2
Keywords: Cc:
Blocked By: Blocking:

Description

Code like below will fail if the Object passed to set() was created in another frame:

dijit.byId("myForm").set('value', {
	cb1: ["foo"],
	cb2: [],
	cb3: ["on"],
	cb4: [],
	cb5: ["on"],
	cb6: ["foo"],
	'g[1]': "", // weather
	g2: "country"
});

The problem is that _FormMixin ends up calling:

lang.isArray(values)

where values is the ["foo"] array above, and isArray() returns false.

Then a few lines later it ends up doing a array.indexOf([ [ "foo" ] ], "foo") call.

This isn't necessarily a defect in Form, since we've never claimed that cross-frame set() calls work, but OTOH people may be expecting them to work. It's tricky though to check array-ness cross-frame. One possibility might be

typeof values != "string" && "length" in values

I noticed this issue in CheckBox_mouse.html. Apparently the only reason the setValues() test is passing is due to side effects from #16104, which causes array.indexOf([ [ "foo" ] ], "foo") to return true. Presumably another cross frame test case would fail, and the current test starts failing if indexOf() is updated to use === rather than ==.

So, it seems like we should either fix Form.set() to work cross frame, and/or move the non-mouse related tests in CheckBox_mouse.html to a non-robot test file.

Change History (2)

comment:1 Changed 6 years ago by Douglas Hays

Resolution: fixed
Status: newclosed

In [30522]:

Fixes #16514. Found that [].concat(val) is great for converting scalar or array values into arrays and works cross-frame.

comment:2 Changed 6 years ago by Douglas Hays

Milestone: tbd1.9
Note: See TracTickets for help on using tickets.