Skip to content

Commit

Permalink
GRAILS-3468: Better pass-through for non null values
Browse files Browse the repository at this point in the history
String values not equal to 'false' or 'true' (case insensitive) or null will be passed
changes to the output. This will enhance compatibility with existing code.
  • Loading branch information
denisfalqueto committed Jan 30, 2012
1 parent d29e99d commit 094e02f
Showing 1 changed file with 8 additions and 4 deletions.
Expand Up @@ -212,12 +212,16 @@ class FormTagLib {
* disabled, readonly and checked.
*/
private void booleanToAttribute(def attrs, String attrName) {
// We'll not remove the value, so it will be passed along if it's not a boolean
def attrValue = attrs.get(attrName)
def attrValue = attrs.remove(attrName)
// If the value is the same as the name or if it is a boolean value,
// reintroduce the attribute to the map, so it is output later
if (attrValue && (attrValue.equalsIgnoreCase(attrName) || Boolean.valueOf(attrValue))) {
// reintroduce the attribute to the map according to the w3c rules, so it is output later
if (Boolean.valueOf(attrValue) ||
(attrValue instanceof String && attrValue?.equalsIgnoreCase(attrName))) {
attrs.put(attrName, attrName)
} else if (attrValue instanceof String && !attrValue?.equalsIgnoreCase('false')) {
// If the value is not the string 'false', then we should just pass it on to
// keep compatibility with existing code
attrs.put(attrName, attrValue)
}
}

Expand Down

0 comments on commit 094e02f

Please sign in to comment.