Commit graph

6 commits

Author SHA1 Message Date
Krinkle
0e82a6cfd0 Applying whitespace conventions in core JS files.
* Mostly whitespace in callers: $('foo').bar(baz,quux) => $( 'foo' ).bar( baz, quux )
* Also several occurrences of mixes spaces and tabs in the indention in front of a line, converted to tabs.
* And double spaces -> single spaces at random.
2011-08-12 21:48:10 +00:00
Krinkle
39cb0c19d5 Use .prop instead of .attr where appropriate
* Although jQuery covers for us in most cases (since .prop didn't exist before jQuery 1.6 and many people abused .attr in laziness of doing their own loop and setting the property manually). It's better to know what we're doing and call the function we intend to call. Both because jQuery may decide to stop rerouting common mistakes to .prop and because it makes code more readable.

* Aside from switching to prop, for boolean properties also replacing null/undefined with false and 'propname' with true. This is no longer being covered by jQuery when using prop directly (as it shouldn't). When an element is created the HTML specification says that the attribute should be set to it's name (ie. '<foo selected="selected">'), the properties however must remain boolean.

* Changing the attribute value for a boolean property (ie. checkbox.setAttribute( 'checked', 'checked' ) does not make the checkbox enabled. All it does is set the attribute. The reason this works with jQuery's attr() is because jQuery calls .prop internally after a bunch of checking inside attr().


-- Reference --
The list of keys that .attr and .removeAttr jQuery is currently (as of jQuery 1.6.1) remapping to use .prop and .removeProp can be found here:
b22c904652/src/attributes.js (L425)
{
	tabindex: "tabIndex",
	readonly: "readOnly",
	"for": "htmlFor",
	"class": "className",
	maxlength: "maxLength",
	cellspacing: "cellSpacing",
	cellpadding: "cellPadding",
	rowspan: "rowSpan",
	colspan: "colSpan",
	usemap: "useMap",
	frameborder: "frameBorder",
	contenteditable: "contentEditable"
}
In addition to those, jQuery also maps these boolean properties to .prop when they are passed to .attr:
	rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,

(source: b22c904652/src/attributes.js (L9) )
2011-08-12 21:19:45 +00:00
Krinkle
bc0f9cac32 Wrapping core modules (FIXME from r79929)
(Touch: r74088, r73046)
2011-01-31 19:33:16 +00:00
Krinkle
85d5e617d7 Removing unneeded wraps and using $ and mw instead of jQuery or mediaWiki since r79246 enabled the private scope by default. No need for two wraps.
(the wraps had an extra indention, hence the diff will probably look huge)
2011-01-10 05:33:03 +00:00
Krinkle
c563312d90 clean-up trailing spaces and tabs in js/css resources 2010-11-12 23:10:58 +00:00
Krinkle
e2e6fb563b moved jQuery.fn.enableCheckboxShiftClick to it's own file and renamed to jQuery.fn.checkboxShiftClick 2010-10-27 15:02:18 +00:00