Last modified: 2014-06-19 16:57:12 UTC
mw.html Scribunto library methods such as css, cssText and attr must remove such attribute or property when passed a nil value. The habit / good pracitce in fluent interface is, that if null is passed, it means that such thing is to be removed. It allows to not clutter the source code with stuff like html = mw.html.create( "tag" ) if( classname ) html:attr( "class", classname ) end and uses the whole potential of the *fluent* interface thus html = mw.html.create( "tag" ) :attr( "class", classname ) which is set if classname is filled or unset(=removed) when it's nil. Same with css html = mw.html.create( "tag" ) :css( "background", background ) will set the background property if set, or remove from style declaration if nil. It also allows effective removal of the previously set stuff: -- default setting html = mw.html.create( "tag" ) :css( "background", background ) :attr( "class", classname ) -- (some code goes here which sets some conditions) -- based on the condition we decided to remove the preciously set background if ( condition ) html:css( "background", nil ) end
*** This bug has been marked as a duplicate of bug 62982 ***
This is not a dupe. This is intentionally opened new bug after discussion with Hoo on IRC, particularly because it requires *different* behavior than bug 62982. This bug requires attribute/property removal for nil, bug 62982 requires no-op on nil.
Fixed with https://gerrit.wikimedia.org/r/137659