Minified.js Beta 6: Features and Changes

Beta 6 will likely be the last Minified beta. It contains a large number of smaller improvements and prepares Minified for the next step. Expect some surprises!

Backward-incompatible Changes

  • $.request()'s promise signatures have changed a bit. The xml document is not part of the response anymore, nor is the status text in the error handler. Instead both now include a reference to the XHR object. I apologize to anyone who's inconvenienced by that, but it didn't really make sense to include them in the first place. You can still get the data from the XHR though.
  • values() will no longer ignore form elements without name if they have an id instead.
  • extend() and copyObj() will now also copy nulls and inherited properties.

New: Merging objects with merge()

merge() takes a list of objects and creates a new one that includes the properties of all given objects.

var merged = _.merge([{a: 1}, {b: 2}, {c: 3}]);   // creates object {a: 1, b: 2, c: 3}

New: Adding new prefixes to set() and get()

The universal set() property names can now be extended with new custom prefixes, using MINI.setter and MINI.getter.

// Adding XLink attribute support to get() and set(). This is useful if you work with SVG. The prefix is '>'.
MINI.getter['>'] = function(list, name) {
	return list[0].getAttributeNS('', name);
MINI.setter['>'] = function(list, name, value) {
	list.each(function(obj, index) {
		if (value == null)
			obj.removeAttributeNS('', name);
			obj.setAttributeNS('', name, value);

New: ES6-style promise resolution

In addition to the original way to fulfilling or rejecting a promise(), by calling it as a function, beta 6 supports the ES6-style of promise resolution:

// A simple promise that is fulfilled after 1 second:
var p = _.promise(function(resolve, reject) {
	setTimeout(resolve, 1000);

New: Passing several objects to HTML() and ht() templates

HTML() and ht() can now take more than one object as parameter for the template. The objects will be automatically merged.

// A simple promise that is fulfilled after 1 second:
var p = _.promise(function(resolve, reject) {
	setTimeout(resolve, 1000);

Change: _.request() allows access to XmlHttpRequest

request() has several improvements, albeit some of them incompatible to previous versions. The promises do not return the XML object on success and the status text on error anymore. Instead they contain the XmlHttpRequest object that can be used to obtain them and other properties that were not available before. In addition to that, the XmlHttpRequest object has also been added as property in the returned promise, so you can access it outside of the handlers.

Change: _.request() can be stop()'d

request() also supports stop() to abort a running HTTP request.

Change: values() uses id if form element has no name

values() will now use a field's id if a field has no name but only an id. In many cases this means that you do not have to declare both.

Change: up() allows getting more than one ancestor

up() has got a new, optional parentNum parameter to select not only the direct parent, but also additional ancestors.

Change: Bubble selectors for onClick() and onChange(), work with select fields

onClick() and onChange() allow you to specify a bubble selector (also known as live selector). In addition to that, onChange() also supports select fields now.

Change: Support for contexts in $$()

For consistency, $$()'s arguments are not the same as $()'s.

Change: Shallow copy of objects with _.copyObj()

copyObj() will duplicate an object when called with only one argument. It will also now copy nulls and inherited properties.


You can download beta 6 on the download page.