https://bugzilla.wikimedia.org/show_bug.cgi?id=66166
Bug ID: 66166
Summary: mw.html Scribunto library methods such as css, cssText
and attr must remove such attribute or property when
passed a nil value
Product: MediaWiki extensions
Version: unspecified
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: Unprioritized
Component: Scribunto
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected]
Web browser: ---
Mobile Platform: ---
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
--
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l