This repository has been archived by the owner on Jul 31, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple-dom-helper.js
57 lines (45 loc) · 1.51 KB
/
simple-dom-helper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"use strict";
var domElementFactory = require( "./lib/domElementFactory" ),
domElementListFactory = require( "./lib/domElementListFactory" );
function create( tagName, args ) {
var $element = domElementFactory( document.createElement( tagName ) );
if ( args ) {
$element.bulkEdit( args );
}
return $element;
}
function createFromElement( element ) {
return domElementFactory( element );
}
function createFromElementList( elementList ) {
return domElementListFactory( elementList );
}
function getElementById( id ) {
return domElementFactory( document.getElementById( id ) );
}
function getElementByClassName( className ) {
return domElementFactory( document.getElementsByClassName( className )[ 0 ] );
}
function getElementByTagName( tagName ) {
return domElementFactory( document.getElementsByTagName( tagName )[ 0 ] );
}
function getElementsByClassName( className ) {
return domElementListFactory( document.getElementsByClassName( className ) );
}
function getElementsByTagName( tagName ) {
return domElementListFactory( document.getElementsByTagName( tagName ) );
}
module.exports = {
create: create,
createFromElement: createFromElement,
createFromElementList: createFromElementList,
getElementById: getElementById,
getElementByClassName: getElementByClassName,
getElementByTagName: getElementByTagName,
getElementsByClassName: getElementsByClassName,
getElementsByTagName: getElementsByTagName,
_elements: {
DomElement: require( "./lib/DomElement" ),
DomElementList: require( "./lib/DomElementList" )
}
};