-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
51 lines (40 loc) · 1.11 KB
/
index.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
'use strict';
const Parser = require('./lib/parser');
const cssSelect = require('css-select');
const Helper = require('./lib/helper');
const Attributes = require('./lib/api/attributes');
const Clone = require('./lib/api/clone');
const DomMethods = require('./lib/api/dom-methods');
const IntertionAround = require('./lib/api/insertion-around');
const IntertionInside = require('./lib/api/insertion-inside');
const IntertionOutside = require('./lib/api/insertion-outside');
const Removal = require('./lib/api/removal');
var Shorio = {
defaultOptions: { },
load(html, options = {}) {
const opt = Object.assign({}, Shorio.defaultOptions, options);
Shorio.DOM = Parser.parse(html, opt);
return Shorio.select;
},
select(cssQuery) {
let domSelected = cssSelect(cssQuery, Shorio.DOM.children);
return Shorio.getAllMethods(Shorio.DOM, domSelected);
},
getAllMethods(DOM, selector) {
return Object.assign(
{
DOM,
selector
},
Helper,
Attributes,
Clone,
DomMethods,
IntertionAround,
IntertionInside,
IntertionOutside,
Removal
);
}
};
module.exports = Object.create(Shorio);