Module puredom
-
Core functionality
- Version 1.9.1
- Defined in: puredom.js
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
puredom(arg)
When called as a function, acts as an alias of puredom.el.
|
| Field Attributes | Field Name and Description |
|---|---|
| <static> |
puredom.eventTypeMap
Automatically translate DOM event types from [key] to [value] when registering or removing listeners.
|
Method Summary
| Method Attributes | Method Name and Description |
|---|---|
| <static> |
puredom.
addNodeSelectionPlugin
(name, func)
Add a new plugin method to {puredom.NodeSelection}.
|
| <static> |
puredom.
delve
(obj, path, discardFirst, allowIncompleteMatch)
Get a value from within a nested object.
|
| <static> |
puredom.
el
(query, log)
Create or retrieve one or more elements based on a query.
|
| <static> |
puredom.
extend
(base, props)
Extend/augment a base object with the properties of one or more additional objects.
|
| <static> |
puredom.
flattenObj
(obj, prefix, depth, flat)
Flatten a nested Object using underscore-delimited keys.
|
| <static> |
puredom.
forEach
(obj, iterator)
Iterate over an object, calling an
iterator function on each value. |
| <static> |
puredom.
hasOwnProp
(obj, prop)
Determine if an object has a direct property with the given name.
|
| <static> |
puredom.
inherits
(baseClass, superClass)
Simple prototypal inheritance.
|
| <static> |
puredom.
isArray
(what)
Determine if the argument is an Array
|
| <static> |
puredom.
isScalar
(what)
Determines if the passed object is scalar.
|
| <static> |
puredom.
log
()
Log to the browser console, if it exists.
|
| <static> |
puredom.
mixin
(base, props)
Mix functionality from one object into another.
|
| <static> |
puredom.
node
(uuid)
Get a selection (puredom.NodeSelection) containing the node with the given UUID.
|
| <static> |
puredom.
strip
(obj, andProto)
Strip an object of all of its properties.
|
| <static> |
puredom.
template
(text, fields, allowI18n)
Inject arbitrarily nested template fields into a string of text.
|
| <static> |
puredom.
toArray
(obj)
Convert an Array-like object (having a length and numeric properties) into an Array.
|
| <static> |
puredom.
typeOf
(what)
Get the lowercase type (constructor name) of an object.
|
Module Detail
puredom(arg)
When called as a function, acts as an alias of puredom.el.
If a
Otherwise, all arguments are passed on to puredom.el.
If a
Function is passed, it is registered as a DOMReady handler. Otherwise, all arguments are passed on to puredom.el.
- Parameters:
- {Function|Any} arg
- If a
Functionis passed, it is registered as a DOMReady handler. Otherwise, all arguments are passed on to puredom.el
Field Detail
<static>
puredom.eventTypeMap
Automatically translate DOM event types from [key] to [value] when registering or removing listeners.
Also falsifies corresponding puredom-wrapped events' type fields.
Also falsifies corresponding puredom-wrapped events' type fields.
Method Detail
-
<static> puredom.addNodeSelectionPlugin(name, func)Add a new plugin method to {puredom.NodeSelection}.
When called, a plugin function gets passed the arguments supplied by the caller.
The value ofthiswithin the function is the selection (puredom.NodeSelection) it was called on.- Parameters:
- {String} name
- A method name to define on {puredom.NodeSelection}
- {Function} func
- The plugin method to define.
-
<static> puredom.delve(obj, path, discardFirst, allowIncompleteMatch)Get a value from within a nested object. "Deep keys" use dot notation.
- Parameters:
- {Object} obj
- The object to delve into.
- {String} path
- A dot-notated key to find within
obj - {Boolean} discardFirst Optional, Default: false
- If
true, the first segment ofpathwill be discarded. - {Boolean} allowIncompleteMatch Optional, Default: false
- If
true, returns the deepest reachable value, even if it is not a full path.
-
Create or retrieve one or more elements based on a query.
If query begins with "<" or is an object, a new element is contructed based on that information.
If the query is a CSS selector, DOM nodes matching that selector are returned.- Parameters:
- {String|Object} query
- A CSS selector (retrieval), or a DOM description (creation).
- {Boolean} log Optional, Default: false
- If true, query process will be logged to the console.
- Returns:
- {puredom.NodeSelection} selection
-
<static> {Object} puredom.extend(base, props)Extend/augment a base object with the properties of one or more additional objects.
Note: all additional arguments are treated as additional Objects to copy properties from.var clonedObj = puredom.extend({}, originalObj); puredom.extend(MyClass.prototype, prototypeAsHash);- Parameters:
- {Object} base
- The object to extend. For cloning, use an object literal.
- {Object} props
- An Object to copy properties from.
- {Object} ... Optional
- Additional arguments also get copied onto base.
- Returns:
- {Object} base
-
<static> {Object} puredom.flattenObj(obj, prefix, depth, flat)Flatten a nested Object using underscore-delimited keys. (
foo_bar_baz)- Parameters:
- {Object} obj
- The nested/deep object to flatten
- {Any}prefix
- {Any}depth
- {Any}flat
- Returns:
- {Object} flat
-
<static> puredom.forEach(obj, iterator)Iterate over an object, calling an
iteratorfunction on each value.- Parameters:
- {Object|Array} obj
- An object to iterate over.
- {Function} iterator
- A function to call for each value. Gets passed
(value, key).
- Returns:
- obj
-
<static> {Boolean} puredom.hasOwnProp(obj, prop)Determine if an object has a direct property with the given name.
- Parameters:
- {Any} obj
- An object to test
- {String} prop
- A property name to test
- Returns:
- {Boolean} hasOwnProperty
-
<static> {Function} puredom.inherits(baseClass, superClass)Simple prototypal inheritance.
puredom.inherits(puredom.ControllerManager, puredom.EventEmitter);
- Parameters:
- {Function} baseClass
- The base (child) class.
- {Function} superClass
- A class to inherit from.
- Returns:
- {Function} baseClass, for convenience
-
<static> {Boolean} puredom.isArray(what)Determine if the argument is an Array
- Parameters:
- {Any} what
- An object to analyze
- Returns:
- {Boolean} isArray
trueif the object is anArray, otherwisefalse.
-
<static> {Boolean} puredom.isScalar(what)Determines if the passed object is scalar.
- Parameters:
- {Any} what
- An object to analyze
- Returns:
- {Boolean} isScalar
-
<static> puredom.log()Log to the browser console, if it exists.
-
<static> {Object} puredom.mixin(base, props)Mix functionality from one object into another.
Note: all additional arguments are treated as additional Objects to copy properties from.
Alternative Signature:mixin(true, [props, ...], base)// standard: puredom.mixin(myObj, decorator1, decorator2); // alternative, decorator-first style: puredom.mixin(true, decorator1, decorator2, myObj);
- Parameters:
- {Object} base
- The object to extend. For cloning, use an object literal.
- {Object} props
- An Object to copy properties from, unless base already has a property of the same name.
- Returns:
- {Object} base
-
Get a selection (puredom.NodeSelection) containing the node with the given UUID.
UniqueIDs can be retrieved using puredom.NodeSelection#uuid.- Parameters:
- {String} uuid
- Unique node ID, such as one derived from puredom.NodeSelection#uuid.
- Returns:
- {puredom.NodeSelection} selection A selection (puredom.NodeSelection) containing the referenced node.
-
<static> puredom.strip(obj, andProto)Strip an object of all of its properties.
Note: Sets property values to null, doesn't actually delete them.- Parameters:
- {Object} obj
- An object to strip all properties from
- {Boolean} andProto Optional, Default: false
- If
true, nullifies entire prototype chain.
-
<static> {String} puredom.template(text, fields, allowI18n)Inject arbitrarily nested template fields into a string of text.
Fields are referenced like this: {foo.bar.baz|truncate:300,byWord}
Note: keys are CaSe-SeNsItIvE.- Parameters:
- {String} text
- The text to template
- {Object} fields
- An object containing (nested) keys for replacement
- {Boolean} allowI18n Optional, Default: true
- Allow Internationalization using the engine referenced by puredom.l18n?
- Returns:
- {String} The templated text
-
<static> {Array} puredom.toArray(obj)Convert an Array-like object (having a length and numeric properties) into an Array.
- Parameters:
- {Any} obj
- An Array-like object to convert
- Returns:
- {Array} array The converted
Arrayon success, or the original objectobjon failure.
-
<static> {String} puredom.typeOf(what)Get the lowercase type (constructor name) of an object.
Important Note: Unlike many other typeOf implementations, this method returns the name of an Object's constructor, rather than just "object".puredom.typeOf({}) === 'object' puredom.typeOf([]) === 'array' puredom.typeOf(new Audio) === 'audio'- Parameters:
- {Any} what
- An object to analyze
- Returns:
- {String} type