Last modified: 2014-06-19 16:57:12 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T68166, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 66166 - mw.html Scribunto library methods such as css, cssText and attr must remove such attribute or property when passed a nil value
mw.html Scribunto library methods such as css, cssText and attr must remove s...
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Scribunto (Other open bugs)
master
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
usability
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-06-05 08:22 UTC by Danny B.
Modified: 2014-06-19 16:57 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Danny B. 2014-06-05 08:22:08 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
Comment 1 Jackmcbarn 2014-06-05 14:21:58 UTC

*** This bug has been marked as a duplicate of bug 62982 ***
Comment 2 Danny B. 2014-06-05 20:17:55 UTC
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.
Comment 3 Marius Hoch 2014-06-19 16:57:12 UTC
Fixed with https://gerrit.wikimedia.org/r/137659

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links