back to Overview

MINI.getter

Exposes a map of prefix handlers used by get.
Web module only.

Syntax

MINI.getter

Description

Exposes a map of prefix handlers used by get(). You can add support for a new prefix in get() by adding a function to this map. The prefix can be any string consisting solely of non-alphanumeric characters that's not already used by Minified.

You must not replace getters by a new map, but must always modify the existing map.

The function's signature is function(list, name) where

list
Is the Minified list to get the value from. By convention you should always use only the first element. The list is non-empty and the first elememt can't be null or undefined (get() automatically returns undefined in all other case).
name
The name of the property. That's the part AFTER the prefix.
(callback return value)
The value to return to the user.

Example

Adding a shortcut '||' for accessing border style properties:

MINI.getter['||'] = function(list, name) {
	return list.get('$border' + name.replace(/^[a-z]/, function(a) { return a.toUpperCase()});
};

var borderColor = $('#box').get('||color'); // same as '$borderColor'
var borderLeftRadius = $('#box').get('||leftRadius'); // same as '$borderLeftRadius'

Example

Adding XLink attribute support to get(). This is useful if you work with SVG. The prefix is '>'.

MINI.getter['>'] = function(list, name) {
	return list[0].getAttributeNS('http://www.w3.org/1999/xlink', name);
};

var xlinkHref = $('#svgLink').get('>href');

Comments

comments powered by Disqus

back to Overview

Functions