Skip to content

A class based on NodeList/HTMLCollection classes that proxies some Element methods like addEventListener, remove, classList

Notifications You must be signed in to change notification settings

clovislima/htmlstock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Dependencies

Classes

HTMLStock
HTMLStockClassList
HTMLStockHelper
Element
Node
HTMLDocument

HTMLStock

Kind: global class
this: HTMLStock
Access: public
Since: 0.1.0

new HTMLStock(arrayLike)

HTMLStock is an abstraction of HTMLCollection and NodeList Classes to be used

Param Type Description
arrayLike object A NodeList, HTMLCollection or an Array Like object containing HTMLElements or undefined properties

htmlStock._map(func, _this) ⇒

HTMLStock._map is an abstraction of Array's map that returns a HTMLStock instance instead of an Array

Kind: instance method of HTMLStock
Returns: HTMLStock
this: HTMLStock
Access: public
Since: 0.1.0

Param Type Description
func function A function that will be used on every element of the HTMLStock
_this object An object to be passed as the function's context

htmlStock._filter(func, _this) ⇒

HTMLStock._filter is an abstraction of Array's filter that returns a HTMLStock instance instead of an Array

Kind: instance method of HTMLStock
Returns: HTMLStock
this: HTMLStock
Access: public
Since: 0.1.0

Param Type Description
func function A function that will be used to validate every element of the HTMLStock, it will keep the elements that return truthfully in the function execution
_this object An object to be passed as the function's context

htmlStock._reduce(func, [initialValue])

HTMLStock._reduce is an implementation of Array.prototype.reduce for HTMLStock

Kind: instance method of HTMLStock
Access: public
Since: 0.1.0

Param Type Description
func function Function to execute on each value
[initialValue] Optional. Value to use as the first argument to the first call of the callback.

htmlStock._reduceRight(func, [initialValue])

HTMLStock._reduceRight is an implementation of Array.prototype.reduceRight for HTMLStock

Kind: instance method of HTMLStock
Access: public
Since: 0.1.0

Param Type Description
func function Function to execute on each value
[initialValue] Optional. Value to use as the first argument to the first call of the callback.

htmlStock._forEach(func, [thisArg])

HTMLStock._forEach is an implementation of Array.prototype.forEach for HTMLStock

Kind: instance method of HTMLStock
Access: public
Since: 0.1.0

Param Type Description
func function Function to execute for each element
[thisArg] Optional. Value to use as this when executing callback.

htmlStock._every(func, [thisArg])

HTMLStock._every is an implementation of Array.prototype.every for HTMLStock

Kind: instance method of HTMLStock
Access: public
Since: 0.1.0

Param Type Description
func function Function to execute on each value
[thisArg] Optional. Value to use as this when executing callback.

htmlStock._some(func, [thisArg])

HTMLStock._some is an implementation of Array.prototype.some for HTMLStock

Kind: instance method of HTMLStock
Access: public
Since: 0.1.0

Param Type Description
func function Function to test for each element
[thisArg] Optional. Value to use as this when executing callback.

htmlStock._addEventListener(type, func, [options], [useCapture])

HTMLStock._addEventListener is a proxy to use the HTMLStock's elements addEventListener

Kind: instance method of HTMLStock
Access: public
Since: 0.1.0

Param Type Description
type string A string representing the event type to listen for.
func function The object that receives a notification when an event of the specified type occurs. This must be an object implementing the EventListener interface, or simply a JavaScript function.
[options] object An options object that specifies characteristics about the event listener
[useCapture] boolean A Boolean that indicates that events of this type will be dispatched to the registered listener before being dispatched to any EventTarget beneath it in the DOM tree. Events that are bubbling upward through the tree will not trigger a listener designated to use capture. Event bubbling and capturing are two ways of propagating events that occur in an element that is nested within another element, when both elements have registered a handle for that event. The event propagation mode determines the order in which elements receive the event. See DOM Level 3 Events and JavaScript Event order for a detailed explanation. If not specified, useCapture defaults to false.

htmlStock._listen(type, func, [options], [useCapture])

HTMLStock._listen is a proxy to use the HTMLStock's elements addEventListener

Kind: instance method of HTMLStock
Access: public
Since: 0.1.0

Param Type Description
type string A string representing the event type to listen for.
func function The object that receives a notification when an event of the specified type occurs. This must be an object implementing the EventListener interface, or simply a JavaScript function.
[options] object An options object that specifies characteristics about the event listener
[useCapture] boolean A Boolean that indicates that events of this type will be dispatched to the registered listener before being dispatched to any EventTarget beneath it in the DOM tree. Events that are bubbling upward through the tree will not trigger a listener designated to use capture. Event bubbling and capturing are two ways of propagating events that occur in an element that is nested within another element, when both elements have registered a handle for that event. The event propagation mode determines the order in which elements receive the event. See DOM Level 3 Events and JavaScript Event order for a detailed explanation. If not specified, useCapture defaults to false.

htmlStock._removeEventListener(type, func, [options], [useCapture])

HTMLStock._removeEventListener is a proxy to use the HTMLStock's elements removeEventListener

Kind: instance method of HTMLStock
Access: public
Since: 0.1.0

Param Type Description
type string A string representing the event type to remove.
func function The EventListener function to remove from the event target.
[options] object An options object that specifies characteristics about the event listener
[useCapture] boolean Specifies whether the EventListener to be removed is registered as a capturing listener or not. If this parameter is absent, a default value of false is assumed.

htmlStock._unlisten(type, func, [options], [useCapture])

HTMLStock._unlisten is a proxy to use the HTMLStock's elements removeEventListener

Kind: instance method of HTMLStock
Access: public
Since: 0.1.0

Param Type Description
type string A string representing the event type to remove.
func function The EventListener function to remove from the event target.
[options] object An options object that specifies characteristics about the event listener
[useCapture] boolean Specifies whether the EventListener to be removed is registered as a capturing listener or not. If this parameter is absent, a default value of false is assumed.

htmlStock._remove()

HTMLStock._remove is a proxy to use the HTMLStock's childNodes remove

Kind: instance method of HTMLStock
Access: public
Since: 0.1.0

htmlStock._insertAdjacentHTML(position, text)

HTMLStock._insertAdjacentHTML is a proxy to use the HTMLStock's elements insertAdjacentHTML

Kind: instance method of HTMLStock
Access: public
Since: 0.1.0

Param Type Description
position string position is the position relative to the element.
text string text is the string to be parsed as HTML or XML and inserted into the tree.

HTMLStockClassList

Kind: global class
this: HTMLStockClassList
Access: public
Since: 0.1.0

new HTMLStockClassList(instance)

HTMLStockClassList is a proxy to access the classList property of the Elements inside the HTMLStock

Param Type Description
instance HTMLStockClassList An initiated instance of HTMLStockClassList

htmlStockClassList._add(classes)

HTMLStockClassList._add is a proxy to use the HTMLStock's elements classList.add

Kind: instance method of HTMLStockClassList
Access: public
Since: 0.1.0

Param Type Description
classes Array.<string> Class values. If these classes already exist in attribute of the element, then they are ignored.

htmlStockClassList._remove(classes)

HTMLStockClassList._remove is a proxy to use the HTMLStock's elements classList.remove

Kind: instance method of HTMLStockClassList
Access: public
Since: 0.1.0

Param Type Description
classes Array.<string> Class values.

htmlStockClassList._toggle(classes)

HTMLStockClassList._toggle is a proxy to use the HTMLStock's elements classList.toggle

Kind: instance method of HTMLStockClassList
Access: public
Since: 0.1.0

Param Type Description
classes Array.<string> Class values. When only one argument is present: Toggle class value; i.e., if class exists then remove it, if not, then add it. When a second argument is present: If the second argument is true, add specified class value, and if it is false, remove it.

HTMLStockHelper

Kind: global class
this: HTMLStockClassList
Access: public
Since: 0.1.0

new HTMLStockHelper(instance)

Helper that copies some methods from other prototypes, as well create some of HTMLStock methods

Param Type Description
instance HTMLStockClassList An initiated instance of HTMLStockClassList

htmlStockHelper.buildHTMLStockClassListProto(prop)

Proxy a given property to every classList HTMLStock HTMLElements

Kind: instance method of HTMLStockHelper
Access: public
Since: 0.1.0

Param Type Description
prop string The property name that will be proxied HTMLStock elements

htmlStockHelper.applyMethodToElements(conf, [_classMethod]) ⇒

Proxy a given method to every HTMLStock HTMLElements

Kind: instance method of HTMLStockHelper
Returns: HTMLStockHelper
Access: public
Since: 0.1.0

Param Type Description
conf string | object An object with the alias and prop names, if as string is passed then the alias will be the same but with a _ (underscore) in front of it
[_classMethod] string A classMethod name that can be passed on so the property will be accessed

htmlStockHelper.applySetterToElements(conf) ⇒

Proxy a given value to every HTMLStock HTMLElements through a setter

Kind: instance method of HTMLStockHelper
Returns: HTMLStockHelper
Access: public
Since: 0.1.0

Param Type Description
conf string | object An object with the alias and prop names, if as string is passed then the alias will be the same but with a _ (underscore) in front of it

htmlStockHelper.aliasMethods(propObj, _class) ⇒

A factory for aliases methods for a Class that will use the original Class methods but return a HTMLStock

Kind: instance method of HTMLStockHelper
Returns: HTMLStockHelper
Access: public
Since: 0.1.0

Param Type Description
propObj string | object An object with the alias and prop names, if as string is passed then the alias will be the same but with a _ (underscore) in front of it
_class function A Class that will have the alias builtin

htmlStockHelper.aliasGetters(propObj, _class) ⇒

A factory for aliases getters for a Class that will use the original Class getter but return a HTMLStock

Kind: instance method of HTMLStockHelper
Returns: HTMLStockHelper
Access: public
Since: 0.1.0

Param Type Description
propObj string | object An object with the alias and prop names, if as string is passed then the alias will be the same but with a _ (underscore) in front of it
_class function A Class that will have the alias builtin

htmlStockHelper.copyProto(prop, _class) ⇒

Copy properties from a Class.prototype to HTMLStock.prototype

Kind: instance method of HTMLStockHelper
Returns: HTMLStockHelper
Access: public
Since: 0.1.0

Param Type Description
prop string the target property
_class function A Class that will have its prototype property copied

htmlStockHelper.callMethods() ⇒

Delegates a method based on the arguments passed

Kind: instance method of HTMLStockHelper
Returns: HTMLStockHelper
Access: public
Since: 0.1.0

htmlStockHelper.delegateCall(delegated, props, _class) ⇒

Calls a method passing the properties and the class that will be used by it

Kind: instance method of HTMLStockHelper
Returns: HTMLStockHelper
Access: public
Since: 0.1.0

Param Type Description
delegated string HTMLStockHelper method that will be called
props Array An array with strings or objects with the property/alias that will be passed to the method
_class function The target Class

htmlStockHelper.extendNative()

Extend some Native Classes and prototypes like Element, Node and HTMLDocument

Kind: instance method of HTMLStockHelper
Access: public
Since: 0.1.0

Element

Kind: global class
Access: public

new Element()

The Element interface represents an object of a Document. This interface describes methods and properties common to all kinds of elements. Specific behaviors are described in interfaces which inherit from Element but add additional functionality. For example, the HTMLElement interface is the base interface for HTML elements, while the SVGElement interface is the basis for all SVG elements.

element._querySelectorAll() ⇒

A querySelectorAll alias that returns a HTMLStock instead of NodeList

Kind: instance method of Element
Returns: HTMLStock
Access: public
Since: 0.1.0

element._findAll() ⇒

A querySelectorAll alias that returns a HTMLStock instead of NodeList

Kind: instance method of Element
Returns: HTMLStock
Access: public
Since: 0.1.0

Node

Kind: global class
Access: public
Properties

Name Type Description
Node.prototype._children HTMLStock A children alias that returns a HTMLStock instead of HTMLCollection
Node.prototype._childNodes HTMLStock A childNodes alias that returns a HTMLStock instead of HTMLCollection

new Node()

A Node is an interface from which a number of DOM types inherit, and allows these various types to be treated (or tested) similarly.

node._parents() ⇒

Returns all parentNodes from an Element until it reaches the HTMLBodyElement

Kind: instance method of Node
Returns: HTMLStock
this: HTMLElement
Access: public
Since: 0.1.0

HTMLDocument

Kind: global class
Access: public
Properties

Name Type Description
HTMLDocument.prototype._children HTMLStock A children alias that returns a HTMLStock instead of HTMLCollection
HTMLDocument.prototype._childNodes HTMLStock A childNodes alias that returns a HTMLStock instead of HTMLCollection

new HTMLDocument()

HTMLDocument is an abstract interface of the DOM which provides access to special properties and methods not present by default on a regular (XML) document.

htmlDocument._querySelectorAll() ⇒

A querySelectorAll alias that returns a HTMLStock instead of NodeList

Kind: instance method of HTMLDocument
Returns: HTMLStock
Access: public
Since: 0.1.0

htmlDocument._findAll() ⇒

A querySelectorAll alias that returns a HTMLStock instead of NodeList

Kind: instance method of HTMLDocument
Returns: HTMLStock
Access: public
Since: 0.1.0

About

A class based on NodeList/HTMLCollection classes that proxies some Element methods like addEventListener, remove, classList

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published