Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Readme
A simple dom helper if you want to get rid of jQuery.
You can use it with the commonjs or amd pattern otherwise it will just inject to window.domHelper
npm install domel
var domel = require( "domel" );
// general selector
domel( ".myid .subclass" ); // a list of matching elements
// get by class
domel.byClass( "my-class" ); // a list of elements
// get by id
var myEl = domel.byId( "my-id" ); // a single element
myEl.d.addClass( "foo" ).d.show()
This module will add a d
property to every retuned dom element.
So you can use at least every domel function without adding the element el.d.{function}()
.
You can even just add this helper by calling domel.domel( el )
.
find
Use a selector to find dom elements
Returns: (Element|HTMLCollection) Returns all matching elements or an array of elements.
If onlyFirst
is true
only the fist element will be returned.
direct usage:
domel( selector [, context = document][, onlyFirst = false] )
wrapped usage by .d
:
el.d.find( selector[, onlyFirst = false] )
byClass
get sub elements by class. If no context
is defined document
will be used.
Returns: (Element|HTMLCollection) Returns all matching elements or an array of elements.
If onlyFirst
is true
only the fist element will be returned.
direct usage:
domel.byClass( _cl [, context = document][, onlyFirst = false] )
wrapped usage by .d
:
el.d.byClass( _cl[, onlyFirst = false] )
byId
get an element by id
Returns: (Element) Returns the matching element
direct usage:
domel.byId( _id [, context = document] )
wrapped usage by .d
:
el.d.byId( _id )
create
create a new dom element
Returns: (Element) the new created element
direct usage:
domel.create( [tag="DIV"][, attributes={} ] )
attr
get or set attributes of an element
Returns: (String|Element) Returns the attribute if no setVal
was defined. Otherwise the element self for chaining.
direct usage:
domel.attr( el, key [, setVal ] )
wrapped usage by .d
:
el.d.attr( key [, setVal ] )
data
get the data attributes of an element
Returns: (String|Object|Element) Returns elements data as object of the value if a key
was defined and no setVal
was defined. If the key
and setVal
are defined the the element self will be returned for chaining.
direct usage:
domel.data( el, key [, setVal ] )
wrapped usage by .d
:
el.d.data( key [, setVal ] )
last
the last element matching the selector
Returns: (Element) Returns the matching element
direct usage:
domel.last( el, selector )
wrapped usage by .d
:
el.d.last( selector )
first
the first element matching the selector
Returns: (Element) Returns the matching element
direct usage:
domel.first( el, selector )
wrapped usage by .d
:
el.d.first( selector )
parent
the parent element or a parent up on the tree if a selector was set
Returns: (Element) Returns the parent element
direct usage:
domel.parent( el [, selector] )
wrapped usage by .d
:
el.d.parent( selector )
children
all direct children or all direct children matching the selector
Returns: (HTMLCollection) Returns all matching elements
direct usage:
domel.children( el, selector )
wrapped usage by .d
:
el.d.children( selector )
countChildren
all direct children or all direct children matching the selector
Returns: (Number) Returns the number of children
direct usage:
domel.countChildren( el, selector )
wrapped usage by .d
:
el.d.countChildren( selector )
is
test the element against a selector
Returns: (Boolean) This element matches the selector
direct usage:
domel.is( el, selector )
wrapped usage by .d
:
el.d.is( selector )
hasClass
check if the element has the given css class
Returns: (Boolean) This element has the class
direct usage:
domel.hasClass( el, classname )
wrapped usage by .d
:
el.d.hasClass( classname )
addClass
add a css class
Returns: (Element) Returns the element for chaining
direct usage:
domel.addClass( element, classname )
wrapped usage by .d
:
el.d.addClass( classname )
removeClass
remove a css class
Returns: (Element) Returns the element for chaining
direct usage:
domel.removeClass( element, classname )
wrapped usage by .d
:
el.d.removeClass( classname )
hide
hide the element by setting style="display:none"
Returns: (Element) Returns the element for chaining
direct usage:
domel.hide( el )
wrapped usage by .d
:
el.d.hide()
show
show the element by setting style="display:{display}"
Returns: (Element) Returns the element for chaining
direct usage:
domel.show( el [, display = "block"] )
wrapped usage by .d
:
el.d.show( [display = "block"] )
hasId
check if the element.id matches the given id
Returns: (Boolean) The id matches the given id
direct usage:
domel.hasId( el, id )
wrapped usage by .d
:
el.d.hasId( id )
append
Append html to a element
Returns: (Element) Returns the element for chaining
direct usage:
domel.append( el, html )
wrapped usage by .d
:
el.d.append( html )
prepend
Prepend html to a element
Returns: (Element) Returns the element for chaining
direct usage:
domel.prepend( el, html )
wrapped usage by .d
:
el.d.prepend( html )
remove
Remove the element from the dom
Returns: (Element) Returns the removed element
direct usage:
domel.remove( el )
wrapped usage by .d
:
el.d.remove()
replaceWith
replace an element with another
Returns: (Element) Returns the replaced element
direct usage:
domel.replaceWith( el, newEl )
wrapped usage by .d
:
el.d.replaceWith( newEl )
clone
deep clone a element
Returns: (Element) Returns the cloned node
direct usage:
domel.clone( el )
wrapped usage by .d
:
el.d.clone()
on
listen to a dom event.
Returns: (Element) Returns the removed element
direct usage:
domel.on( el, type, handler )
wrapped usage by .d
:
el.d.on( type, handler )
off
remove to dom event listener.
Returns: (Element) Returns the removed element
direct usage:
domel.off( el, type, handler )
wrapped usage by .d
:
el.d.off( type, handler )
emit
emit an event manually
Returns: (Element) Returns the removed element
direct usage:
domel.emit( el, type )
wrapped usage by .d
:
el.d.emit( type )
domel
add the .d
helper to an element
Returns: (Element) Returns extended object
direct usage:
domel.domel( el )
Version | Date | Description |
---|---|---|
0.1.0 | 2015-9-17 | bugfixes; added methods: domel , create , attr , replaceWith , clone ; Changed compiler to browserify + coffeeify |
0.0.2 | 2015-9-16 | export fix |
0.0.1 | 2015-9-16 | Initial commit |
Initially Generated with generator-mpnodemodule
Copyright © 2015 M. Peter, http://www.tcs.de
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
A simple dom helper if you want to get rid of jQuery
The npm package domel receives a total of 4 weekly downloads. As such, domel popularity was classified as not popular.
We found that domel demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.