zopefoundation / z3c.form

An advanced form and widget framework for Zope 3
Other
8 stars 39 forks source link

Latest IE11 11.0.16 update break OrderedSelectWidget #23

Closed fredvd closed 8 years ago

fredvd commented 9 years ago

The recently pushed out IE11 security update from february 10th 2015 causes a javascript error in the edit template of the OrderedSelectWidget. Users might not notice the error and upon save already selected items in the widget are lost: and empty widget is saved back tot the content item.

Specifically these lines cause the problem in IE11 in orderedselect_input.pt:

// create virtual node with suitable attributes
var newNode = document.createElement("input");

.......

newAttr = document.createAttribute("type");
newAttr.nodeValue = "hidden";
newNode.setAttributeNode(newAttr);

It will throw a "member not found" error. See attached screenshot.

Setting other attributes using setAttributeNode are fine, but setting type="hidden" gives problems. My temporary fix in a customer project where I have a controlled environment on the browser versions used (latest IE11, recent Firefox), is using "setAttribute":

var newNode = document.createElement("input");
newNode.setAttribute("name", name.replace(/-/g, '.')+':list');
newNode.setAttribute("type", "hidden");
newNode.setAttribute("value",toSel.options[i].value );

But I haven't been able to verify this for other/older browsers and check for compatibility of the .setAttribute method.

setattributenode

mgedmin commented 9 years ago

Would you like to prepare a pull request for this?

datakurre commented 9 years ago

@fredvd How about trying the old way at first, wrapping it into try {} catch {}, and on error, do it in the new way. Or the other way aroud?

fredvd commented 9 years ago

@mgedmin I'd have no problem to create a PR, but I'm on wintersport vacation this week, typing on mobile now.

@datakurre Doing a try/catch could help for ensuring backwards compat. But I'm a lousy javascript/frontender. Was Already surprises I figured this out myself :-P

What worries me most about the current widget implementation is that if it doesn't initialise properly, like the current issue, the incomplete/empty data is saved back. If we could add a failsafe for that somehow... but maybe it introduces only more complexity that can fail.

fredvd commented 9 years ago

Btw. When I searched for similar issues I found this unsolved issue report from jquery .attr() that looks like this case. They also mention other attribute named/values. http://bugs.jquery.com/ticket/12577