als-document 0.6.11 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/document.js +21 -10
- package/document.mjs +804 -0
- package/package.json +3 -6
- package/readme.md +10 -3
- package/test/{html1.js → data/html1.js} +1 -2
- package/test/{html2.js → data/html2.js} +1 -1
- package/test/front-test/html.html +5650 -0
- package/test/front-test/html.js +3218 -0
- package/test/front-test/test.html +18 -0
- package/test/front-test/test.js +129 -0
- package/test/test.html +17 -0
- package/test/test.js +15 -19
- package/test/tests/document-test.js +402 -0
- package/test/tests/parser-test.js +99 -0
- package/test/tests/query-test.js +71 -0
- package/test/tests/selector-test.js +169 -0
- package/test/utils/__dirname.js +6 -0
- package/test/utils/als-simple-test/test.mjs +153 -0
- package/test/utils/iframe.js +4 -0
- package/document/document.js +0 -192
- package/document/test.js +0 -678
- package/document.min.js +0 -1
- package/index.js +0 -6
- package/parser/parser.js +0 -340
- package/parser/test.js +0 -233
- package/query/query.js +0 -147
- package/query/readme.md +0 -134
- package/query/test.js +0 -143
- package/selector/selector.js +0 -126
- package/selector/test.js +0 -410
package/document/test.js
DELETED
|
@@ -1,678 +0,0 @@
|
|
|
1
|
-
let Test = require('als-test')
|
|
2
|
-
let Document = require('./document')
|
|
3
|
-
const { notEqual, smaller, greater } = require('als-test')
|
|
4
|
-
let {equal} = Test
|
|
5
|
-
|
|
6
|
-
module.exports = new Test('Document tests',[
|
|
7
|
-
{
|
|
8
|
-
title:'Create $',
|
|
9
|
-
result: function({html1}){
|
|
10
|
-
this.vars.$ = new Document(html1)
|
|
11
|
-
this.vars.code1 = /*html*/`<div id="test-id"><span>test</span>Hello world<span>test 2</span></div>`
|
|
12
|
-
return 'Done'
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
title:'Check selector',
|
|
17
|
-
expected:14,
|
|
18
|
-
result: function({$}){
|
|
19
|
-
return $.$('div').index
|
|
20
|
-
},
|
|
21
|
-
action:equal
|
|
22
|
-
},
|
|
23
|
-
{title:'Insert tests'},
|
|
24
|
-
{
|
|
25
|
-
title:'insert before',
|
|
26
|
-
expected:'test-id',
|
|
27
|
-
result: function({$,code1}){
|
|
28
|
-
let div = $.$('div')
|
|
29
|
-
div.insert(code1,0)
|
|
30
|
-
return $.$('div').id
|
|
31
|
-
},
|
|
32
|
-
action:equal
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
title:'Check if new element, includes it\'s children',
|
|
36
|
-
expected:'Hello world',
|
|
37
|
-
result: function({$}){
|
|
38
|
-
return $.$('div').children[1].text
|
|
39
|
-
},
|
|
40
|
-
action:equal
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
title:'Check if new element, includes it\'s children',
|
|
44
|
-
expected:'test',
|
|
45
|
-
result: function({$}){
|
|
46
|
-
return $.$('div').children[0].innerHTML
|
|
47
|
-
},
|
|
48
|
-
action:equal
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
title:'Move existing element',
|
|
52
|
-
expected:'test-id',
|
|
53
|
-
result: function({$}){
|
|
54
|
-
let div = $.$('div')
|
|
55
|
-
let script = $.$('script')
|
|
56
|
-
script.insert(div,0)
|
|
57
|
-
return script.prev.id
|
|
58
|
-
},
|
|
59
|
-
action:equal
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
title:'Insert after',
|
|
63
|
-
expected:'test-id',
|
|
64
|
-
result: function({$}){
|
|
65
|
-
let div = $.$('div')
|
|
66
|
-
let script = $.$('script')
|
|
67
|
-
script.insert(div,3)
|
|
68
|
-
return script.next.id
|
|
69
|
-
},
|
|
70
|
-
action:equal
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
title:'Insert as first child',
|
|
74
|
-
expected:'script',
|
|
75
|
-
result: function({$}){
|
|
76
|
-
let script = $.$('script')
|
|
77
|
-
let div = $.$('div')
|
|
78
|
-
div.insert(script,1)
|
|
79
|
-
return div.children[0].tag
|
|
80
|
-
},
|
|
81
|
-
action:equal
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
title:'Insert as last child',
|
|
85
|
-
expected:'script',
|
|
86
|
-
result: function({$}){
|
|
87
|
-
let span = $.$('span')
|
|
88
|
-
let script = $.$('script')
|
|
89
|
-
span.insert(script,2)
|
|
90
|
-
return span.children[1].tag
|
|
91
|
-
},
|
|
92
|
-
action:equal
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
title:'setter before - number of parent children',
|
|
96
|
-
expected:function({$}) {
|
|
97
|
-
return $.$('.headers').children.length
|
|
98
|
-
},
|
|
99
|
-
result:function({$}) {
|
|
100
|
-
$.$('.headers>label').before = '<div id="test1">Test</div>'
|
|
101
|
-
return $.$('.headers').children.length
|
|
102
|
-
},
|
|
103
|
-
action:smaller
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
title:'setter before - index of element',
|
|
107
|
-
expected:function({$}) {
|
|
108
|
-
return $.$('.headers').index
|
|
109
|
-
},
|
|
110
|
-
result:function({$}) {
|
|
111
|
-
let el = $.$('.headers')
|
|
112
|
-
let next = el.next
|
|
113
|
-
el.before = next
|
|
114
|
-
return el.prev.index
|
|
115
|
-
},
|
|
116
|
-
action:equal
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
title:'setter after - number of parent children',
|
|
120
|
-
expected:function({$}) {
|
|
121
|
-
return $.$('.headers').children.length
|
|
122
|
-
},
|
|
123
|
-
result:function({$}) {
|
|
124
|
-
$.$('.headers>label').after = '<div id="test2">Test</div>'
|
|
125
|
-
return $.$('.headers').children.length
|
|
126
|
-
},
|
|
127
|
-
action:smaller
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
title:'setter after - index of element',
|
|
131
|
-
expected:function({$}) {
|
|
132
|
-
return $.$('.headers').endIndex+1
|
|
133
|
-
},
|
|
134
|
-
result:function({$}) {
|
|
135
|
-
let el = $.$('.headers')
|
|
136
|
-
let el2 = el.prev
|
|
137
|
-
el.after = el2
|
|
138
|
-
return el2.index + el2.elements.length
|
|
139
|
-
},
|
|
140
|
-
action:equal
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
title:'first - childIndex',
|
|
144
|
-
expected:0,
|
|
145
|
-
result:function({$}) {
|
|
146
|
-
let tabs = $.$('.tabs')
|
|
147
|
-
let child = tabs.children[1]
|
|
148
|
-
tabs.first = child
|
|
149
|
-
return child.childIndex
|
|
150
|
-
},
|
|
151
|
-
action:equal
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
title:'first - index',
|
|
155
|
-
expected:function({$}) {
|
|
156
|
-
return $.$('.tabs').children[0].index
|
|
157
|
-
},
|
|
158
|
-
result:function({$}) {
|
|
159
|
-
let tabs = $.$('.tabs')
|
|
160
|
-
let child = tabs.children[2]
|
|
161
|
-
tabs.first = child
|
|
162
|
-
return child.index
|
|
163
|
-
},
|
|
164
|
-
action:equal
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
title:'last - childIndex',
|
|
168
|
-
expected:function({$}){
|
|
169
|
-
let tabs = $.$('.tabs')
|
|
170
|
-
let last = tabs.children.length-1
|
|
171
|
-
return tabs.children[last].childIndex
|
|
172
|
-
},
|
|
173
|
-
result:function({$}) {
|
|
174
|
-
let tabs = $.$('.tabs')
|
|
175
|
-
let child = tabs.children[0]
|
|
176
|
-
tabs.last = child
|
|
177
|
-
return child.childIndex
|
|
178
|
-
},
|
|
179
|
-
action:equal
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
title:'last - index',
|
|
183
|
-
expected:function({$}) {
|
|
184
|
-
let tabs = $.$('.tabs')
|
|
185
|
-
let last = tabs.children.length-1
|
|
186
|
-
return tabs.children[last].index
|
|
187
|
-
},
|
|
188
|
-
result:function({$}) {
|
|
189
|
-
let tabs = $.$('.tabs')
|
|
190
|
-
let child = tabs.children[0]
|
|
191
|
-
let gap = child.elements.length
|
|
192
|
-
tabs.last = child
|
|
193
|
-
return child.index-gap
|
|
194
|
-
},
|
|
195
|
-
action:equal
|
|
196
|
-
},
|
|
197
|
-
{title:'Attributes action tests'},
|
|
198
|
-
{
|
|
199
|
-
title:'Get element\'s style property',
|
|
200
|
-
expected:'none',
|
|
201
|
-
result:function({$}){
|
|
202
|
-
return $.$('[style*="display"]').style.display
|
|
203
|
-
},
|
|
204
|
-
action:equal
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
title:'Change element\'s style property',
|
|
208
|
-
expected:'block',
|
|
209
|
-
result:function({$}){
|
|
210
|
-
let element = $.$('[style*="display"]')
|
|
211
|
-
element.style.display = 'block'
|
|
212
|
-
return element.style.display
|
|
213
|
-
},
|
|
214
|
-
action:equal
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
title:'Changins element\'s style, change attribs.style too',
|
|
218
|
-
expected:true,
|
|
219
|
-
result:function({$}){
|
|
220
|
-
let element = $.$('[style*="display"]')
|
|
221
|
-
element.style.display = 'flex'
|
|
222
|
-
return element.attribs.style.includes('flex')
|
|
223
|
-
},
|
|
224
|
-
action:equal
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
title:'Deleting element\'s style property',
|
|
228
|
-
expected:undefined,
|
|
229
|
-
result:function({$}){
|
|
230
|
-
let element = $.$('[style*="display"]')
|
|
231
|
-
delete element.style.display
|
|
232
|
-
return element.style.display
|
|
233
|
-
},
|
|
234
|
-
action:equal
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
title:'Deleting element\'s style, change attribs.style too',
|
|
238
|
-
expected:false,
|
|
239
|
-
result:function({$}){
|
|
240
|
-
let element = $.$('[style*="background-color"]')
|
|
241
|
-
delete element.style.backgroundColor
|
|
242
|
-
return element.attribs.style.includes('background-color')
|
|
243
|
-
},
|
|
244
|
-
action:equal
|
|
245
|
-
},
|
|
246
|
-
{title:'Classlist action tests'},
|
|
247
|
-
{
|
|
248
|
-
title:'add class',
|
|
249
|
-
expected:true,
|
|
250
|
-
result: function({$}){
|
|
251
|
-
let el = $.$('.tabs')
|
|
252
|
-
el.classList.add('super')
|
|
253
|
-
return el.classList.includes('super')
|
|
254
|
-
},
|
|
255
|
-
action:equal
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
title:'Adding class, changing attribs.class too',
|
|
259
|
-
expected:true,
|
|
260
|
-
result: function({$}){
|
|
261
|
-
let el = $.$('.tabs')
|
|
262
|
-
el.classList.add('puper')
|
|
263
|
-
return el.attribs.class.includes('puper')
|
|
264
|
-
},
|
|
265
|
-
action:equal
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
title:'remove class',
|
|
269
|
-
expected:function({$}) {
|
|
270
|
-
return $.$('.tabs').classList.includes('super')
|
|
271
|
-
},
|
|
272
|
-
result: function({$}){
|
|
273
|
-
let el = $.$('.tabs')
|
|
274
|
-
el.classList.remove('super')
|
|
275
|
-
return el.classList.includes('super')
|
|
276
|
-
},
|
|
277
|
-
action:notEqual
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
title:'Removing class, removing class in attribs.class too',
|
|
281
|
-
expected:function({$}) {
|
|
282
|
-
return $.$('.tabs').attribs.class.includes('puper')
|
|
283
|
-
},
|
|
284
|
-
result: function({$}){
|
|
285
|
-
let el = $.$('.tabs')
|
|
286
|
-
el.classList.remove('puper')
|
|
287
|
-
return el.attribs.class.includes('puper')
|
|
288
|
-
},
|
|
289
|
-
action:notEqual
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
title:'Test id getter',
|
|
293
|
-
expected:'test-id',
|
|
294
|
-
result:function({$}){
|
|
295
|
-
return $.$('[id]').id
|
|
296
|
-
},
|
|
297
|
-
action:equal
|
|
298
|
-
},
|
|
299
|
-
{
|
|
300
|
-
title:'Test id setter',
|
|
301
|
-
expected:'another-one',
|
|
302
|
-
result:function({$}){
|
|
303
|
-
$.$('[id]').id = 'another-one'
|
|
304
|
-
return $.$('[id]').id
|
|
305
|
-
},
|
|
306
|
-
action:equal
|
|
307
|
-
},
|
|
308
|
-
{title:'Test attributes'},
|
|
309
|
-
{
|
|
310
|
-
title:'Get attribute',
|
|
311
|
-
expected:function({$}) {
|
|
312
|
-
return $.$('input').attribs.type
|
|
313
|
-
},
|
|
314
|
-
result:function({$}){
|
|
315
|
-
return $.$('input').attr('type')
|
|
316
|
-
},
|
|
317
|
-
action:equal
|
|
318
|
-
},
|
|
319
|
-
{
|
|
320
|
-
title:'Set attribute',
|
|
321
|
-
expected:function({$}) {
|
|
322
|
-
return $.$('input').attribs.name
|
|
323
|
-
},
|
|
324
|
-
result:function({$}){
|
|
325
|
-
let input = $.$('input')
|
|
326
|
-
input.attr('name','name-changed')
|
|
327
|
-
return input.attr('name')
|
|
328
|
-
},
|
|
329
|
-
action:notEqual
|
|
330
|
-
},
|
|
331
|
-
{
|
|
332
|
-
title:'Remove attribute',
|
|
333
|
-
expected:function({$}) {
|
|
334
|
-
return Object.keys($.$('input').attribs).includes('checked')
|
|
335
|
-
},
|
|
336
|
-
result:function({$}){
|
|
337
|
-
let input = $.$('input')
|
|
338
|
-
input.attr('checked',null)
|
|
339
|
-
return Object.keys($.$('input').attribs).includes('checked')
|
|
340
|
-
},
|
|
341
|
-
action:notEqual
|
|
342
|
-
},
|
|
343
|
-
{
|
|
344
|
-
title:'Style not changable',
|
|
345
|
-
expected:function({$}) {
|
|
346
|
-
return $.$('[style]').attr('style')
|
|
347
|
-
},
|
|
348
|
-
result:function({$}){
|
|
349
|
-
$.$('[style]').attr('style','style has changed')
|
|
350
|
-
return $.$('[style]').attr('style')
|
|
351
|
-
},
|
|
352
|
-
action:equal
|
|
353
|
-
},
|
|
354
|
-
{
|
|
355
|
-
title:'Id not changable',
|
|
356
|
-
expected:function({$}) {
|
|
357
|
-
return $.$('[id]').attr('id')
|
|
358
|
-
},
|
|
359
|
-
result:function({$}){
|
|
360
|
-
$.$('[id]').attr('id','id has changed')
|
|
361
|
-
return $.$('[id]').attr('id')
|
|
362
|
-
},
|
|
363
|
-
action:equal
|
|
364
|
-
},
|
|
365
|
-
{
|
|
366
|
-
title:'Class not removable',
|
|
367
|
-
expected:function({$}) {
|
|
368
|
-
return $.$('[class]').attr('class')
|
|
369
|
-
},
|
|
370
|
-
result:function({$}){
|
|
371
|
-
$.$('[class]').attr('class',null)
|
|
372
|
-
return $.$('[class]').attr('class')
|
|
373
|
-
},
|
|
374
|
-
action:equal
|
|
375
|
-
},
|
|
376
|
-
{
|
|
377
|
-
title:'style not removable',
|
|
378
|
-
expected:function({$}) {
|
|
379
|
-
return $.$('[style]').attr('style')
|
|
380
|
-
},
|
|
381
|
-
result:function({$}){
|
|
382
|
-
$.$('[style]').attr('style',null)
|
|
383
|
-
return $.$('[style]').attr('style')
|
|
384
|
-
},
|
|
385
|
-
action:equal
|
|
386
|
-
},
|
|
387
|
-
{
|
|
388
|
-
title:'id not removable',
|
|
389
|
-
expected:function({$}) {
|
|
390
|
-
return $.$('[id]').attr('id')
|
|
391
|
-
},
|
|
392
|
-
result:function({$}){
|
|
393
|
-
$.$('[id]').attr('id',null)
|
|
394
|
-
return $.$('[id]').attr('id')
|
|
395
|
-
},
|
|
396
|
-
action:equal
|
|
397
|
-
},
|
|
398
|
-
{
|
|
399
|
-
title:'outerHTML changing then attribute changing',
|
|
400
|
-
expected:function({$}) {
|
|
401
|
-
return $.$('script').outerHTML.length
|
|
402
|
-
},
|
|
403
|
-
result:function({$}){
|
|
404
|
-
$.$('script').attr('src','some-test')
|
|
405
|
-
return $.$('script').outerHTML.length
|
|
406
|
-
},
|
|
407
|
-
action:notEqual
|
|
408
|
-
},
|
|
409
|
-
{
|
|
410
|
-
title:'remove element - children length',
|
|
411
|
-
expected:function({$}) {
|
|
412
|
-
return $.$('input').parent.children.length
|
|
413
|
-
},
|
|
414
|
-
result:function({$}) {
|
|
415
|
-
let el = $.$('input')
|
|
416
|
-
let parent = el.parent
|
|
417
|
-
el.remove()
|
|
418
|
-
return parent.children.length
|
|
419
|
-
},
|
|
420
|
-
action:greater
|
|
421
|
-
},
|
|
422
|
-
{
|
|
423
|
-
title:'remove element - parent elements change',
|
|
424
|
-
expected:function({$}) {
|
|
425
|
-
return $.$('input').parent.elements.length
|
|
426
|
-
},
|
|
427
|
-
result:function({$}) {
|
|
428
|
-
let el = $.$('input')
|
|
429
|
-
let count = el.elements.length
|
|
430
|
-
let parent = el.parent
|
|
431
|
-
el.remove()
|
|
432
|
-
return parent.elements.length+count
|
|
433
|
-
},
|
|
434
|
-
action:equal
|
|
435
|
-
},
|
|
436
|
-
{
|
|
437
|
-
title:'remove element - innerHTML changed',
|
|
438
|
-
expected:function({$}) {
|
|
439
|
-
return $.$('input').parent.innerHTML.length
|
|
440
|
-
},
|
|
441
|
-
result:function({$}) {
|
|
442
|
-
let el = $.$('input')
|
|
443
|
-
let parent = el.parent
|
|
444
|
-
el.remove()
|
|
445
|
-
return parent.innerHTML.length
|
|
446
|
-
},
|
|
447
|
-
action:greater
|
|
448
|
-
},
|
|
449
|
-
{
|
|
450
|
-
title:'Create $',
|
|
451
|
-
result: function({html2}){
|
|
452
|
-
this.vars.$ = new Document(html2)
|
|
453
|
-
return 'Done'
|
|
454
|
-
},
|
|
455
|
-
},
|
|
456
|
-
{
|
|
457
|
-
title:'Check selector',
|
|
458
|
-
expected:89,
|
|
459
|
-
result: function({$}){
|
|
460
|
-
return $.$('div').index
|
|
461
|
-
},
|
|
462
|
-
action:equal
|
|
463
|
-
},
|
|
464
|
-
{title:'Insert tests'},
|
|
465
|
-
{
|
|
466
|
-
title:'insert before',
|
|
467
|
-
expected:'test-id',
|
|
468
|
-
result: function({$,code1}){
|
|
469
|
-
let div = $.$('div')
|
|
470
|
-
div.insert(code1,0)
|
|
471
|
-
return $.$('div').id
|
|
472
|
-
},
|
|
473
|
-
action:equal
|
|
474
|
-
},
|
|
475
|
-
{
|
|
476
|
-
title:'Check if new element, includes it\'s children',
|
|
477
|
-
expected:'Hello world',
|
|
478
|
-
result: function({$}){
|
|
479
|
-
return $.$('div').children[1].text
|
|
480
|
-
},
|
|
481
|
-
action:equal
|
|
482
|
-
},
|
|
483
|
-
{
|
|
484
|
-
title:'Check if new element, includes it\'s children',
|
|
485
|
-
expected:'test',
|
|
486
|
-
result: function({$}){
|
|
487
|
-
return $.$('div').children[0].innerHTML
|
|
488
|
-
},
|
|
489
|
-
action:equal
|
|
490
|
-
},
|
|
491
|
-
{
|
|
492
|
-
title:'Move existing element',
|
|
493
|
-
expected:'test-id',
|
|
494
|
-
result: function({$}){
|
|
495
|
-
let div = $.$('div')
|
|
496
|
-
let script = $.$('script')
|
|
497
|
-
script.insert(div,0)
|
|
498
|
-
return script.prev.id
|
|
499
|
-
},
|
|
500
|
-
action:equal
|
|
501
|
-
},
|
|
502
|
-
{
|
|
503
|
-
title:'Insert after',
|
|
504
|
-
expected:'test-id',
|
|
505
|
-
result: function({$}){
|
|
506
|
-
let div = $.$('div')
|
|
507
|
-
let script = $.$('script')
|
|
508
|
-
script.insert(div,3)
|
|
509
|
-
return script.next.id
|
|
510
|
-
},
|
|
511
|
-
action:equal
|
|
512
|
-
},
|
|
513
|
-
{
|
|
514
|
-
title:'Insert as first child',
|
|
515
|
-
expected:'script',
|
|
516
|
-
result: function({$}){
|
|
517
|
-
let script = $.$('script')
|
|
518
|
-
let div = $.$('div')
|
|
519
|
-
div.insert(script,1)
|
|
520
|
-
return div.children[0].tag
|
|
521
|
-
},
|
|
522
|
-
action:equal
|
|
523
|
-
},
|
|
524
|
-
{
|
|
525
|
-
title:'Insert as last child',
|
|
526
|
-
expected:'script',
|
|
527
|
-
result: function({$}){
|
|
528
|
-
let span = $.$('span')
|
|
529
|
-
let script = $.$('script')
|
|
530
|
-
span.insert(script,2)
|
|
531
|
-
return span.children[1].tag
|
|
532
|
-
},
|
|
533
|
-
action:equal
|
|
534
|
-
},
|
|
535
|
-
{
|
|
536
|
-
title:'setter before - number of parent children',
|
|
537
|
-
expected:function({$}) {
|
|
538
|
-
return $.$('#container').children.length
|
|
539
|
-
},
|
|
540
|
-
result:function({$}) {
|
|
541
|
-
$.$('#container>#navbarDropMenu').before = '<div id="test1">Test</div>'
|
|
542
|
-
return $.$('#container').children.length
|
|
543
|
-
},
|
|
544
|
-
action:smaller
|
|
545
|
-
},
|
|
546
|
-
{
|
|
547
|
-
title:'setter before - index of element',
|
|
548
|
-
expected:function({$}) {
|
|
549
|
-
return $.$('#container').index
|
|
550
|
-
},
|
|
551
|
-
result:function({$}) {
|
|
552
|
-
let el = $.$('#container')
|
|
553
|
-
let next = el.next
|
|
554
|
-
el.before = next
|
|
555
|
-
return el.prev.index
|
|
556
|
-
},
|
|
557
|
-
action:equal
|
|
558
|
-
},
|
|
559
|
-
{
|
|
560
|
-
title:'setter after - number of parent children',
|
|
561
|
-
expected:function({$}) {
|
|
562
|
-
return $.$('#container').children.length
|
|
563
|
-
},
|
|
564
|
-
result:function({$}) {
|
|
565
|
-
$.$('#container>#navbarDropMenu').after = '<div id="test2">Test</div>'
|
|
566
|
-
return $.$('#container').children.length
|
|
567
|
-
},
|
|
568
|
-
action:smaller
|
|
569
|
-
},
|
|
570
|
-
{
|
|
571
|
-
title:'setter after - index of element',
|
|
572
|
-
expected:function({$}) {
|
|
573
|
-
return $.$('#container').endIndex+1
|
|
574
|
-
},
|
|
575
|
-
result:function({$}) {
|
|
576
|
-
let el = $.$('#container')
|
|
577
|
-
let el2 = el.prev
|
|
578
|
-
el.after = el2
|
|
579
|
-
return el2.index + el2.elements.length
|
|
580
|
-
},
|
|
581
|
-
action:equal
|
|
582
|
-
},
|
|
583
|
-
{
|
|
584
|
-
title:'first - childIndex',
|
|
585
|
-
expected:0,
|
|
586
|
-
result:function({$}) {
|
|
587
|
-
let tabs = $.$('#container')
|
|
588
|
-
let child = tabs.children[1]
|
|
589
|
-
tabs.first = child
|
|
590
|
-
return child.childIndex
|
|
591
|
-
},
|
|
592
|
-
action:equal
|
|
593
|
-
},
|
|
594
|
-
{
|
|
595
|
-
title:'first - index',
|
|
596
|
-
expected:function({$}) {
|
|
597
|
-
return $.$('#container').children[0].index
|
|
598
|
-
},
|
|
599
|
-
result:function({$}) {
|
|
600
|
-
let tabs = $.$('#container')
|
|
601
|
-
let child = tabs.children[2]
|
|
602
|
-
tabs.first = child
|
|
603
|
-
return child.index
|
|
604
|
-
},
|
|
605
|
-
action:equal
|
|
606
|
-
},
|
|
607
|
-
{
|
|
608
|
-
title:'last - childIndex',
|
|
609
|
-
expected:function({$}){
|
|
610
|
-
let tabs = $.$('#container')
|
|
611
|
-
let last = tabs.children.length-1
|
|
612
|
-
return tabs.children[last].childIndex
|
|
613
|
-
},
|
|
614
|
-
result:function({$}) {
|
|
615
|
-
let tabs = $.$('#container')
|
|
616
|
-
let child = tabs.children[0]
|
|
617
|
-
tabs.last = child
|
|
618
|
-
return child.childIndex
|
|
619
|
-
},
|
|
620
|
-
action:equal
|
|
621
|
-
},
|
|
622
|
-
{
|
|
623
|
-
title:'last - index',
|
|
624
|
-
expected:function({$}) {
|
|
625
|
-
let tabs = $.$('#container')
|
|
626
|
-
let last = tabs.children.length-1
|
|
627
|
-
return tabs.children[last].index
|
|
628
|
-
},
|
|
629
|
-
result:function({$}) {
|
|
630
|
-
let tabs = $.$('#container')
|
|
631
|
-
let last = tabs.children[tabs.children.length-1]
|
|
632
|
-
let child = tabs.children[0]
|
|
633
|
-
tabs.last = child
|
|
634
|
-
return child.index+child.elements.length-last.elements.length
|
|
635
|
-
},
|
|
636
|
-
action:equal
|
|
637
|
-
},
|
|
638
|
-
{
|
|
639
|
-
title:'remove element - children length',
|
|
640
|
-
expected:function({$}) {
|
|
641
|
-
return $.$('.w3-bar-item').parent.children.length
|
|
642
|
-
},
|
|
643
|
-
result:function({$}) {
|
|
644
|
-
let el = $.$('.w3-bar-item')
|
|
645
|
-
let parent = el.parent
|
|
646
|
-
el.remove()
|
|
647
|
-
return parent.children.length
|
|
648
|
-
},
|
|
649
|
-
action:greater
|
|
650
|
-
},
|
|
651
|
-
{
|
|
652
|
-
title:'remove element - parent elements change',
|
|
653
|
-
expected:function({$}) {
|
|
654
|
-
return $.$('.w3-bar-item').parent.elements.length
|
|
655
|
-
},
|
|
656
|
-
result:function({$}) {
|
|
657
|
-
let el = $.$('.w3-bar-item')
|
|
658
|
-
let count = el.elements.length
|
|
659
|
-
let parent = el.parent
|
|
660
|
-
el.remove()
|
|
661
|
-
return parent.elements.length+count
|
|
662
|
-
},
|
|
663
|
-
action:equal
|
|
664
|
-
},
|
|
665
|
-
{
|
|
666
|
-
title:'remove element - innerHTML changed',
|
|
667
|
-
expected:function({$}) {
|
|
668
|
-
return $.$('.w3-bar-item').parent.innerHTML.length
|
|
669
|
-
},
|
|
670
|
-
result:function({$}) {
|
|
671
|
-
let el = $.$('.w3-bar-item')
|
|
672
|
-
let parent = el.parent
|
|
673
|
-
el.remove()
|
|
674
|
-
return parent.innerHTML.length
|
|
675
|
-
},
|
|
676
|
-
action:greater
|
|
677
|
-
},
|
|
678
|
-
])
|
package/document.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
class HtmlSelector{constructor(e){"string"==typeof e?(this.html=new HtmlParser(e),this.elements.forEach((e,t)=>{this.makeSelectable(e)})):console.log("Parameter is not string")}get elements(){return this.html.elements}makeSelectable(e){"tag"==e.type&&"close"!==e.status&&(e.$$=t=>this.$$(t,e.index,e.endIndex),e.$=t=>this.$(t,e.index,e.endIndex))}$(e,t=0,s=this.elements.length){return this.$$(e,t,s,!0)}$$(e,t=0,s=this.elements.length,i=!1){let l=[];return(this.selectors=new Query(e).selectors,this.query=e,this.selectors.forEach(e=>{for(let r=t;r<s;r++){let n=this.elements[r];if(this.checkElement(n,e)&&!l.includes(n)&&l.push(n),i&&1==l.length)break}}),i&&1==l.length)?l[0]:i&&0==l.length?null:l}checkElement(e,t){if(void 0==t)return!0;if(null==e)return!1;let{tag:s,classList:i,attribs:l,id:r,prev:n,ancestors:h,parents:a,prevAny:c}=t;return"close"!=e.status&&"text"!=e.type&&(void 0===r||void 0!=e.id)&&(!r||r===e.id)&&(!s||void 0!=e.tag)&&(!s||s===e.tag)&&(void 0===i||void 0!=e.classList)&&(!(void 0!==i&&Array.isArray(e.classList))||!1!=i.every(t=>e.classList.includes(t)))&&!1!=this.checkAttribs(l,e)&&!1!=this.checkElement(e.prev,n)&&!1!=this.checkAncestors(e.ancestors,h)&&!1!=this.checkParents(e.ancestors,a)&&(!e.parent||!1!=this.prevAny(e.parent.children,e.childIndex,c))}prevAny(e=[],t,s){if((0==e.length||0==t)&&s)return!1;for(let i=t;i>=0;i--)if(this.checkElement(e[i],s))return!0;return!1}checkAncestors(e=[],t=[]){let s=0;if(0==t.length)return!0;let i=e.length-1,l=t.length-1;for(;l>=0;){for(let r=i;r>=0;r--)if(i=r-1,!0==this.checkElement(e[r],t[l])){s++;break}l--}return s==t.length}checkParents(e=[],t=[]){if(0==t.length)return!0;if(e.length<t.length)return!1;let s=e.length-1;for(let i=t.length-1;i>=0;i--){if(!1==this.checkElement(e[s],t[i]))return!1;s--}return!0}checkAttribs(e=[],t){let s=t.attribs,i=Object.keys(s),l=0;if(e)for(let r=0;r<e.length;r++){let{name:n,value:h,check:a}=e[r];if("inner"==n&&void 0!==h&&a&&t.innerText&&a(t.innerText)&&l++,i.includes(n)){if(void 0==h)l++;else if(h&&s[n]){if(!1==a(s[n]))continue;l++}}}return l==e.length}}class Query{static get(e){return new Query(e).selectors}constructor(e){this.query=e,this.selectors=[],this.getQueries(e.split(","))}getQueries(e){e.forEach(e=>{let t=e;e=this.removeSpaces(e),this.stringValues=[],e=e.replace(/\[.*?\]/g,e=>(this.stringValues.push(e),`[${this.stringValues.length-1}]`));let[s,i]=this.splitAndCutLast(e," ");s=this.getFamily(s),i.length>0&&(s.ancestors=i.map(e=>this.getFamily(e))),s.group=t,this.selectors.push(s)})}splitAndCutLast(e,t){let s=e.split(t),i;return 1==s.length?(i=s[0],s=[]):i=s.splice(s.length-1,s.length-1)[0],[i,s]}getFamily(e,t,s,i,l){if(null!==e.match(/\~|\+/)){let[r,n]=this.splitAndCutLast(e,/\~|\+/),h=e.replace(r,"");n.forEach(e=>h=h.replace(e,"")),1==(h=h.match(/\~|\+/g)).length?l=h[0]:h.length>1&&(l=h.splice(h.length-1,h.length-1)[0],n[0]=n.map((e,t)=>(t<n.length-1&&(e+=h[t]),e)).join(""),n[0]=this.getFamily(n[0])),"~"==l?i=n[0]:"+"==l&&(s=n[0]),t=r}else t=e;let a;return s||i?(a=this.getParents(t),s&&(a.prev=this.getParents(s)),i&&(a.prevAny=this.getParents(i))):a=this.getParents(t),a.query!==e&&(a.group=e),a}getParents(e){if("string"!=typeof e)return e;{let[t,s]=this.splitAndCutLast(e,">");return t=this.buildElement(t),(s=s.map(e=>this.buildElement(e))).length>0&&(t.parents=s),t}}buildElement(e,t=null,s=null,i=[]){let l=e;e=(e=(e=e.replace(/\#(\w-?)*/,e=>(t=e.replace(/^\#/,""),""))).replace(/\.(\w-?)*/,e=>(i.push(e.replace(/^\./,"")),""))).replace(/(\w-?)*/,e=>(s=""==e?null:e,""));let r=this.getAttributes(e);return e={query:l},t&&(e.id=t),s&&(e.tag=s),i.length>0&&(e.classList=i),r.length>0&&(e.attribs=r),e}getAttributes(e){let t=this.stringValues.filter((t,s)=>{let i=`[${s}]`;return!!e.match(i)});return t.map(e=>{let t=e,[s,i]=(e=e.replace("[","").replace("]","")).split(/[\~\|\^\$\*]?\=/),l=e.replace(s,"").replace(i,"");return e={query:t},s&&(e.name=s),i&&(e.value=i.trim().replace(/^\"/,"").replace(/\"$/,"")),l&&(e.sign=l,e.check=this.getAttribFn(l).bind(e)),e})}getAttribFn(e){return"="==e?function(e){return e==this.value}:"*="==e?function(e){return!!e.includes(this.value)}:"^="==e?function(e){return!!e.startsWith(this.value)}:"$="==e?function(e){return!!e.endsWith(this.value)}:"|="==e?function(e){return!!(1==e.trim().split(" ").length&&(e.startsWith(this.value)||e.startsWith(this.value+"-")))}:"~="==e?function(e){return!!(1==this.value.trim().split(" ").length&&e.includes(this.value))}:void 0}removeSpaces(e){return e=(e=(e=e.replace(/\s{2}/g," ")).replace(/\s?\^?\$?\|?\~?\*?\=\s*/g,e=>e.trim())).replace(/\s?(\+|\~|\>)\s?/g,e=>e.trim())}}class HtmlParser{static parse(e){return new HtmlParser(e).root}constructor(e=""){this.checkHtml(e)&&(this.indexes=[],this.events=[],this.html=this.htmlString=e,this.htmlString=this.htmlString.replace(/\<\!\-\-([\S\s]*?)\-\-\>/gm,""),this.removeScripts(),this.removeStyles(),this.removeEventStrings(),this.root=this.parse(),this.clean())}clean(){["events","indexes","scripts","styles","htmlString","html"].forEach(e=>{delete this[e]})}checkHtml(e,t=!1){return""==e?console.log("html parameter is empty"):"string"!=typeof e?console.log(`html parameter has to be string. Recieved ${typeof e}`):t=!0,t}removeScripts(e=[]){let t=this.htmlString.match(/\<script(.*?)\>[\S\s]*?\<\/script\>/gm);null!==t&&t.forEach((t,s)=>{let i=t.replace(/^\<script(.*?)\>/,"").replace(/\<\/script\>$/,"");e.push(i),this.htmlString=this.htmlString.replace(i,`{{{{script ${e.length-1}`)}),this.scripts=e}removeStyles(e=[]){let t=this.htmlString.match(/\<style\>[\S\s]*?\<\/style\>/gm);null!==t&&t.forEach((t,s)=>{let i=t.replace(/^\<style\>/,"").replace(/\<\/style\>$/,"");e.push(i),this.htmlString=this.htmlString.replace(i,`{{{{style ${e.length-1}`)}),this.styles=e}removeEventStrings(){let e=this.htmlString.match(/\son\w*\s*?\=\s*?\"(.*?)\"/g);null!==e&&e.forEach(e=>{let t=e.split("=").filter((e,t)=>t>0&&""!==t).join("=");t=t.replace(/^\"/,"").replace(/\"$/,""),this.events.push(t);let s=e.replace(t,`{{{{event ${this.events.length-1}`);this.htmlString=this.htmlString.replace(e,s)})}parse(e=this.htmlString){let t=e.match(/<("[^"]*"|'[^']*'|[^'">])*>/g);t.forEach((s,i)=>{t[i]=this.parseElement(s),e=e.replace(s,`<tag${i}>`)});let s=e.match(/tag[\s\S]*?\</g);for(let i=s.length-1;i>=0;i--){let l=s[i],r=l.match(/(\d*)\>/)[1];(l=l.replace(/tag.*\>/,"").slice(0,-1).trim()).length>0&&t.splice(parseInt(r)+1,0,l)}this.elements=t;let n=this.getPairs();return n.level=0,n.elements=this.elements,this.innerHTML(n),n}lookForPair(e,t,s,i){e.parent=s,e.children=[];let{tag:l}=e,r=0,n;for(let h=t+1;h<this.elements.length;h++){let a=this.elements[h];if(a.tag==l){if("close"==a.status){if(0==r){n=h,a.level=i;break}r--}else"open"==a.status&&r++}}return n||(n=t+1),e.endIndex=n,this.getPairs(e,t+1,n,i+1)}getPairs(e={type:"root",children:[]},t=0,s=this.elements.length,i=0,l=0){for(let r=t;r<s;r++){if(this.indexes.includes(r))continue;let n=this.elements[r],h;"string"==typeof n?h=n:"tag"==n.type&&("single"==n.status?(h=n).parent=e:"open"==n.status?h=this.lookForPair(n,r,e,i):n.index=r),this.addChild(e,h,r,i),l++}return e}addScriptsAndStyles(e,t,s){if("script"==e.tag){let i=t.match(/(?<=\{\{\{\{script\s)(\d*)?/);if(null!==i){let l=parseInt(i[0]);"number"==typeof l&&(t=this.scripts[l])}}if("style"==e.tag){let r=t.match(/(?<=\{\{\{\{style\s)(\d*)?/);if(null!==r){let n=parseInt(r[0]);"number"==typeof n&&(t=this.styles[n])}}return this.elements[s]=t,t}addChild(e,t,s,i){"string"==typeof t&&(t={type:"text",text:t=this.addScriptsAndStyles(e,t,s),parent:e},this.elements[s]=t),t&&(delete t.status,"text"!==t.type&&(this.innerHTML(t),this.outerHTML(t),this.innerText(t)),this.getElements(t),this.getAncestors(t),this.getAttribute(t),this.nextAndPrev(t),t.index=s,t.level=i,e.children.push(t)),this.indexes.push(s)}getAttribute(e){e.getAttribute=function(e){let t=Object.keys(this.attribs).filter(t=>t==e);return t.length>0?this.attribs[t[0]]:null}}getAncestors(e){Object.defineProperty(e,"ancestors",{get(){let e=[],t=this.parent;if(t)for(;t.parent;)e.unshift(t),t=t.parent;return e}})}nextAndPrev(e){Object.defineProperty(e,"childIndex",{get(){return this.parent.children.map(e=>e.index).indexOf(this.index)}}),Object.defineProperty(e,"prev",{get(){let e=this.childIndex,t=this.parent.children;return 0==e?null:t[e-1]}}),Object.defineProperty(e,"next",{get(){let e=this.childIndex,t=this.parent.children;return e==t.length-1?null:t[e+1]}})}getElements(e,t=this){"text"!==e.type&&Object.defineProperty(e,"elements",{configurable:!0,get(){let e=isNaN(this.endIndex)?this.index+1:this.endIndex+1;return t.elements.slice(this.index,e)}}),Object.defineProperty(e,"$elements",{configurable:!0,get:()=>t.elements}),Object.defineProperty(e,"root",{configurable:!0,get:()=>t.root}),Object.defineProperty(e,"html",{configurable:!0,get:()=>t})}outerHTML(e){Object.defineProperty(e,"outerHTML",{get(){let{elements:e}=this;return e[0].text+this.innerHTML+e[e.length-1].text}})}innerText(e){Object.defineProperty(e,"innerText",{get:()=>e.children?e.children.map(e=>"text"==e.type?e.text:"").join(""):""})}innerHTML(e){e.tab=" ",e.n="\n",Object.defineProperty(e,"innerHTML",{get(){let{tab:e,n:t}=this,s="",i,l="",{elements:r}=this,n=r.length,h=n-1,a=1;"root"==this.type&&(h=n,a=0);for(let c=a;c<h;c++){let{level:d,text:o}=r[c];void 0==i&&(i=d),c==h?l="":d&&(l=Array.from(Array(d-i).keys()).map(t=>e).join("")),s+=l+o,n>3&&(s+=t)}return s}})}parseElement(e){if("<!DOCTYPE html>"==e)return{tag:"!DOCTYPE html",status:"single",attribs:{},type:"tag",text:e};let t="close",s=e.match(/(?<=\<\/)(\w*\-?)*/);null==s?(s=e.match(/(?<=\<)(\w*\-?)*/))&&(s=s[0],t=HtmlParser.singleTags.includes(s)?"single":"open"):s=s[0];let{classList:i,attribs:l,style:r,id:n,text:h}=this.parseAttributes(e);return{tag:s,status:t,attribs:l,type:"tag",classList:i,text:h,style:r,id:n}}static singleTags=["comment","area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"];parseAttributes(e,t=[],s={},i={},l=null){let r=e,n=e.match(/(?<=\s)(\w*\-?)*(\s*?\=\s*?\"[\s\S]*?\")?/g);return n&&n.forEach(n=>{let h=n.split("="),a=h[0];if(h.length>1&&""!==a){let c=h.filter((e,t)=>t>0).join("="),d=(c=c.trim().replace(/^\"/,"").replace(/\"$/m,"")).match(/(?<=\{\{\{\{event\s)(\d*)?/);null!==d&&(c=this.events[d[0]],r=e.replace(`{{{{event ${d[0]}`,c)),"class"==a?t=c.split(/\s\s?\s?/):"style"==a?i=this.parseInlineCss(c):"id"==a&&(l=c),s[a]=c}else""!==a&&(s[a]=void 0)}),{classList:t,attribs:s,style:i,id:l,text:r}}parseInlineCss(e){let t=e.split(";"),s={};return t.forEach(e=>{let[t,i]=e.trim().split(":");""!==e&&(null!==t.match(/\w*\-\w*(-\w*)?/)&&(t=t.split("-").map((e,t)=>0==t?e:e[0].toUpperCase()+e.slice(1)).join("")),s[t]=i.trim())}),s}}class Document extends HtmlSelector{constructor(e){super(e),this.elements.forEach(e=>{this.addMethods(e)})}addMethods(e){"tag"==e.type&&"close"!==e.status&&(this.insert(e),this.buildAttribs(e),this.classlistMethods(e),this.style(e),this.id(e))}id(e,t=this){(void 0===e.id||!Object.getOwnPropertyDescriptor(e,"id").get)&&(null==e.id||void 0!==e.id)&&("string"==typeof e.id&&delete e.id,Object.defineProperty(e,"id",{get(){return this.attribs.id?this.attribs.id:null},set(e){this.attribs.id=e,t.changeElementText(this)}}))}style(e,t={},s=this){void 0!==e.style&&(t={...e.style});let i=e=>e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);e.style=new Proxy(t,{get(e,t,s){return"target"===t?e:Reflect.get(...arguments)},set(t,l,r){t[l]=r,e.attribs.style=Object.keys(t).map(e=>`${i(e)}:${t[e]};`).join(""),s.changeElementText(this)},deleteProperty(t,l){l in t&&(delete t[l],e.attribs.style=Object.keys(t).map(e=>`${i(e)}:${t[e]};`).join("")),s.changeElementText(this)}})}classlistMethods(e,t=this){void 0==e.classList&&(e.classList=[]),e.classList.add=function(s){void 0==e.attribs.class&&(e.attribs.class=""),this.push(s),e.attribs.class+=" "+s,t.changeElementText(this)},e.classList.remove=function(s){this.splice(this.indexOf(s),1),e.attribs.class=this.filter(e=>void 0!==e).join(" "),t.changeElementText(this)},e.classList.toggle=function(e){this.includes(e)?this.remove(e):this.add(e),t.changeElementText(this)}}buildAttribs(e,t=this){e.attr||(e.attr=function(e,s){if(e&&void 0===s)return this.attribs[e];e&&null===s&&!["class","style","id"].includes(e)?delete this.attribs[e]:e&&null!=s&&!["style","id"].includes(e)&&(this.attribs[e]=s,"class"==e&&(this.classList=s.split(" ").filter(e=>" "!==e),t.classlistMethods(this))),t.changeElementText(this)})}insert(e){let t=this;e.insert=function(e,s=0){let i,l=this.$elements;if("string"==typeof e)(e=new HtmlParser(e)).elements.forEach(e=>{t.html.getElements(e),t.makeSelectable(e),t.addMethods(e)}),i=e.elements,e=e.root.children[0];else{let{index:r,endIndex:n}=e,h=isNaN(n-r)?1:n-r+1;i=l.splice(r,h);let{parent:a,childIndex:c}=e;a.children.splice(c,1)}t.rebildElements(l),t.addElement(this,l,e,i,s)},e.remove=function(){let{$elements:e,elements:s,parent:i,childIndex:l,index:r}=this;e.splice(r,s.length),i.children.splice(l,1),i.endIndex=i.endIndex-s.length,t.rebildElements(e)},Object.defineProperty(e,"before",{set(e){this.insert(e,0)}}),Object.defineProperty(e,"after",{set(e){this.insert(e,3)}}),Object.defineProperty(e,"last",{set(e){this.insert(e,2)}}),Object.defineProperty(e,"first",{set(e){this.insert(e,1)}})}addElement(e,t,s,i,l){let{parent:r,level:n,index:h,endIndex:a}=e;0==l?(t.splice(h,0,...i),r.children.splice(e.childIndex,0,s)):3==l?(t.splice(a+1,0,...i),r.children.splice(e.childIndex+1,0,s)):(1==l||2==l)&&(n+=1,r=e,1==l?(t.splice(h+1,0,...i),e.children.unshift(s)):2==l&&(t.splice(a-1,0,...i),e.children.push(s)),e.endIndex=e.endIndex+i.length),this.rebildElements(t),this.rebuildChild(i[0],r,e.html,n)}rebildElements(e){for(let t=0;t<e.length;t++){let{endIndex:s,index:i}=e[t];if(s){let l=s-i;e[t].endIndex=t+l}e[t].index=t}}rebuildChild(e,t,s,i){void 0!==e.endIndex&&(e.elements[e.elements.length-1].level=i),s.getElements(e,s),e.parent=t,e.level=i,e.children&&e.children.length>0&&e.children.forEach(t=>{this.rebuildChild(t,e,s,i+1)})}changeElementText(e){let{type:t,status:s,attribs:i,tag:l}=e;if("tag"==t&&"close"!==s){let r=Object.keys(i);r=r.length>0?" "+r.map(e=>`${e}${i[e]?`="${i[e]}"`:""}`).join(" "):"",e.text=`<${l}${r}>`}}}
|