nafg/reactive

updateProperty doesn't work for class

Closed this issue · 2 comments

If using properties to update the attributes of element, the update doesn't work in case the attribute is named 'class'.
Cause is the javascript function updateProperty.

Fix should be:

if (propertyName == "class")
p.className = value;
else
p[propertyName] = value;

nafg commented

Hi, for this reason DomProperty and PropertyVar have an extra parameter in case the property name is different than the attribute name. The other main scenario is for/htmlFor.
In any case there are two convenience shortcuts: PropertyVar.className (https://github.com/nafg/reactive/blob/master/reactive-web/src/main/scala/reactive/web/PropertyVar.scala#L137) and PropertyVar.appendClass (https://github.com/nafg/reactive/blob/master/reactive-web/src/main/scala/reactive/web/PropertyVar.scala#L145).

Lately cloudbees has not been successfully updating the site, so the scaladocs there may be somewhat out of date.

Oh, thanks for explanation. That did the trick.