API Docs for: 0.0.1
Show:

ElementArray Class

Module: element-array
Parent Module: vdom

Extends Array into an array with special utility-methods that can be applied upon its members. The membres should be vElement's

Copyright (c) 2014 ITSA - https://github.com/itsa
New BSD License - http://choosealicense.com/licenses/bsd-3-clause/

Methods

append

(
  • content
  • escape
)
chainable

Defined in src/vdom/partials/element-array.js:45

Available since 0.0.1

For all vElements of the ElementArray: Appends a HtmlElement or text at the end of HtmlElement's innerHTML.

Parameters:

  • content HtmlElement | HtmlElementList | String

    content to append

  • escape Boolean

    whether to insert escaped content, leading it into only text inserted

defineInlineStyle

(
  • value
)
chainable

Defined in src/vdom/partials/element-array.js:59

Available since 0.0.1

For all vElements of the ElementArray: Sets the inline-style of the HtmlElement exactly to the specified value, overruling previous values. Making the HtmlElement's inline-style look like: style="value".

This is meant for a quick one-time setup. For individually inline style-properties to be set, you can use setInlineStyle().

Parameters:

  • value String

    the style string to be set

isPlugged

(
  • pluginClass
)
Boolean

Defined in src/vdom/partials/element-array.js:75

Available since 0.0.1

For all vElements of the ElementArray: Checks whether the plugin is plugged in at ALL the HtmlElements of the NodeList/HTMLCollection. Checks whether all its attributes are set.

Parameters:

  • pluginClass NodePlugin

    The plugin that should be plugged. Needs to be the Class, not an instance!

Returns:

Boolean:

whether the plugin is plugged in

plug

(
  • pluginClass
  • options
)
chainable

Defined in src/vdom/partials/element-array.js:91

Available since 0.0.1

For all vElements of the ElementArray: Plugs in the plugin on the HtmlElement, and gives is special behaviour by setting the appropriate attributes.

Parameters:

  • pluginClass NodePlugin

    The plugin that should be plugged. Needs to be the Class, not an instance!

  • options Object

    any options that should be passed through when the class is instantiated.

prepend

(
  • content
  • [escape]
)
chainable

Defined in src/vdom/partials/element-array.js:105

Available since 0.0.1

For all vElements of the ElementArray: Prepends a HtmlElement or text at the start of HtmlElement's innerHTML.

Parameters:

  • content HtmlElement | HtmlElementList | String

    content to prepend

  • [escape] Boolean optional

    whether to insert escaped content, leading it into only text inserted

removeAttr

(
  • attributeName
  • [silent=false]
)
chainable

Defined in src/vdom/partials/element-array.js:119

Available since 0.0.1

For all vElements of the ElementArray: Removes the attribute from the HtmlElement.

Alias for removeAttribute().

Parameters:

  • attributeName String
  • [silent=false] Boolean optional

    prevent node-mutation events by the Event-module to emit

removeAttrs

(
  • attributeData
  • [silent=false]
)
chainable

Defined in src/vdom/partials/element-array.js:135

Available since 0.0.1

For all vElements of the ElementArray: Removes multiple attributes on the Element. The argument should be one ore more AttributeNames.

Parameters:

  • attributeData Array | String
  • [silent=false] Boolean optional

    prevent node-mutation events by the Event-module to emit

Example:

instance.removeAttrs(['tabIndex', 'style']);

removeClass

(
  • className
)
chainable

Defined in src/vdom/partials/element-array.js:153

Available since 0.0.1

For all vElements of the ElementArray: Removes a className from the HtmlElement.

Parameters:

  • className String

    the className that should be removed.

removeData

(
  • key
)
chainable

Defined in src/vdom/partials/element-array.js:166

Available since 0.0.1

For all vElements of the ElementArray: Removes data specified by key. When no arguments are passed, all node-data (key-value pairs) will be removed.

Parameters:

removeInlineStyle

(
  • cssAttribute
)
chainable

Defined in src/vdom/partials/element-array.js:179

Available since 0.0.1

For all vElements of the ElementArray: Removes a css-property (inline) out of the HtmlElement. Use camelCase.

Parameters:

  • cssAttribute String

    the css-property to be removed

removeNode

()

Defined in src/vdom/partials/element-array.js:192

Available since 0.0.1

For all vElements of the ElementArray: Removes the HtmlElement from the DOM.

replaceClass

(
  • prevClassName
  • newClassName
  • [force
)
chainable

Defined in src/vdom/partials/element-array.js:206

Available since 0.0.1

For all vElements of the ElementArray: Replaces the className of the HtmlElement with a new className. If the previous className is not available, the new className is set nevertheless.

Parameters:

  • prevClassName String

    the className to be replaced

  • newClassName String

    the className to be set

  • [force Boolean

    ] whether the new className should be set, even is the previous className isn't there

replaceNode

(
  • newHtmlElement
  • [escape]
)

Defined in src/vdom/partials/element-array.js:222

Available since 0.0.1

For all vElements of the ElementArray: Replaces the HtmlElement with a new HtmlElement.

Parameters:

  • newHtmlElement HtmlElement | String

    the new HtmlElement

  • [escape] Boolean optional

    whether to insert escaped content, leading it into only text inserted

setAttr

(
  • attributeName
  • value
  • [silent=false]
)
chainable

Defined in src/vdom/partials/element-array.js:242

Available since 0.0.1

For all vElements of the ElementArray: Sets the attribute on the HtmlElement with the specified value.

Alias for setAttribute().

Parameters:

  • attributeName String
  • value Any

    the value that belongs to key

  • [silent=false] Boolean optional

    prevent node-mutation events by the Event-module to emit

setAttrs

(
  • attributeData
  • [silent=false]
)
chainable

Defined in src/vdom/partials/element-array.js:259

Available since 0.0.1

For all vElements of the ElementArray: Sets multiple attributes on the Element with the specified value. The argument should be one ore more Objects with the properties: name and value

Parameters:

  • attributeData Array | Object
  • [silent=false] Boolean optional

    prevent node-mutation events by the Event-module to emit

Example:

instance.setAttrs([ {name: 'tabIndex', value: '0'}, {name: 'style', value: 'color: #000;'} ]);

setClass

(
  • className
)
chainable

Defined in src/vdom/partials/element-array.js:280

Available since 0.0.1

For all vElements of the ElementArray: Adds a class to the HtmlElement. If the class already exists it won't be duplicated.

Parameters:

  • className String

    className to be added

setData

(
  • key
  • value
)
chainable

Defined in src/vdom/partials/element-array.js:293

Available since 0.0.1

For all vElements of the ElementArray: Stores arbitary data at the HtmlElement. This has nothing to do with node-attributes whatsoever, it is just a way to bind any data to the specific Element so it can be retrieved later on with getData().

Parameters:

  • key String

    name of the key

  • value Any

    the value that belongs to key

setHTML

(
  • content
)
chainable

Defined in src/vdom/partials/element-array.js:308

Available since 0.0.1

For all vElements of the ElementArray: Sets the content of the HtmlElement (innerHTML). Careful: only set content like this if you controll the data and are sure what is going inside. Otherwise XSS might occur. If you let the user insert, or insert right from a db, you might be better of using setContent().

Parameters:

  • content HtmlElement | HtmlElementList | String

    content to append

setOuterHTML

(
  • val
)
chainable

Defined in src/vdom/partials/element-array.js:339

Available since 0.0.1

For all vElements of the ElementArray: Gets or sets the outerHTML of both the Element as well as the representing dom-node. Goes through the vdom, so it's superfast.

Use this property instead of outerHTML

Syncs with the DOM.

Parameters:

  • val String

    the new value to be set

setStyle

(
  • cssAttribute
  • value
)
chainable

Defined in src/vdom/partials/element-array.js:323

Available since 0.0.1

For all vElements of the ElementArray: Sets a css-property (inline) out of the HtmlElement. Use camelCase.

Note: no need to camelCase cssProperty: both margin-left as well as marginLeft are fine

Parameters:

  • cssAttribute String

    the css-property to be set

  • value String

    the css-value

setText

(
  • content
  • [escape]
)
chainable

Defined in src/vdom/partials/element-array.js:357

Available since 0.0.1

For all vElements of the ElementArray: Sets the content of the HtmlElement. This is a safe way to set the content, because HTML is not parsed. If you do need to set HTML inside the node, use setHTML().

Parameters:

  • content HtmlElement | HtmlElementList | String

    content to append. In case of HTML, it will be escaped.

  • [escape] Boolean optional

    whether to insert escaped content, leading it into only text inserted

toggleClass

(
  • className
)
chainable

Defined in src/vdom/partials/element-array.js:372

Available since 0.0.1

For all vElements of the ElementArray: Toggles the className of the Element.

Parameters:

  • className String

    the className that should be toggled

unplug

(
  • pluginClass
)
chainable

Defined in src/vdom/partials/element-array.js:385

Available since 0.0.1

For all vElements of the ElementArray: Unplugs a NodePlugin from the HtmlElement.

Parameters:

  • pluginClass NodePlugin

    The plugin that should be unplugged. Needs to be the Class, not an instance!