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/selector/test.js
DELETED
|
@@ -1,410 +0,0 @@
|
|
|
1
|
-
let Test = require('als-test')
|
|
2
|
-
// const HtmlSelector = require('./selector')
|
|
3
|
-
const {HtmlSelector} = require('als-document')
|
|
4
|
-
let {equal,greater,smaller,$greater, $smaller} = Test
|
|
5
|
-
|
|
6
|
-
module.exports = new Test('Selector tests',[
|
|
7
|
-
{
|
|
8
|
-
title:'Build $1 and $2',
|
|
9
|
-
result: function({html1,html2}){
|
|
10
|
-
this.vars.$1 = new HtmlSelector(html1)
|
|
11
|
-
this.vars.$2 = new HtmlSelector(html2)
|
|
12
|
-
let {$1,$2} = this.vars
|
|
13
|
-
if(typeof $1.$ == 'function' && typeof $2.$ == 'function')
|
|
14
|
-
return '$1 and $2 created'
|
|
15
|
-
else {
|
|
16
|
-
this.terminate = true
|
|
17
|
-
return 'Selector not created. Test terminated.'
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
{title:'Tests for selecting single element'},
|
|
22
|
-
{
|
|
23
|
-
title:'Get body tag from $1',
|
|
24
|
-
expected:'body',
|
|
25
|
-
result:function({$1}){
|
|
26
|
-
return $1.$('body').tag
|
|
27
|
-
},
|
|
28
|
-
action:equal
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
title:'Get body tag from $2',
|
|
32
|
-
expected:'body',
|
|
33
|
-
result:function({$2}){
|
|
34
|
-
return $2.$('body').tag
|
|
35
|
-
},
|
|
36
|
-
action:equal
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
title:'Get element by className from $1',
|
|
40
|
-
expected:true,
|
|
41
|
-
result:function({$1}){
|
|
42
|
-
return $1.$('.tabs').classList.includes('tabs')
|
|
43
|
-
},
|
|
44
|
-
action:equal
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
title:'Get element by className from $2',
|
|
48
|
-
expected:'https://www.w3schools.com',
|
|
49
|
-
result:function({$2}){
|
|
50
|
-
return $2.$('.w3-button').attribs.href
|
|
51
|
-
},
|
|
52
|
-
action:equal
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
title:'Get element by id from $1',
|
|
56
|
-
expected:'tab3',
|
|
57
|
-
result:function({$1}){
|
|
58
|
-
return $1.$('#tab3').id
|
|
59
|
-
},
|
|
60
|
-
action:equal
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
title:'Get element by id from $2',
|
|
64
|
-
expected:'runbtn',
|
|
65
|
-
result:function({$2}){
|
|
66
|
-
return $2.$('#runbtn').id
|
|
67
|
-
},
|
|
68
|
-
action:equal
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
title:'Get element by attribute from $1',
|
|
72
|
-
expected:'tab1',
|
|
73
|
-
result:function({$1}){
|
|
74
|
-
return $1.$('[name="css-tabs"][type="radio"][checked]').id
|
|
75
|
-
},
|
|
76
|
-
action:equal
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
title:'Get element by attribute from $2',
|
|
80
|
-
expected:'Save',
|
|
81
|
-
result:function({$2}){
|
|
82
|
-
return $2.$('[title="Save"]').attribs.title
|
|
83
|
-
},
|
|
84
|
-
action:equal
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
title:'Get element by attribute name $1',
|
|
88
|
-
expected:'none',
|
|
89
|
-
result:function({$1}){
|
|
90
|
-
return $1.$('[style]').style.display
|
|
91
|
-
},
|
|
92
|
-
action:equal
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
title:'Get element by attribute name $2',
|
|
96
|
-
expected:'trytopnav',
|
|
97
|
-
result:function({$2}){
|
|
98
|
-
return $2.$('[class]').attribs.class
|
|
99
|
-
},
|
|
100
|
-
action:equal
|
|
101
|
-
},
|
|
102
|
-
{title:'Check attributes for single'},
|
|
103
|
-
{
|
|
104
|
-
title:'Test includes - "*=" fro $1',
|
|
105
|
-
expected:'Tab 1',
|
|
106
|
-
result: function({$1}){
|
|
107
|
-
return $1.$('[class*="transition1"]').innerHTML
|
|
108
|
-
},
|
|
109
|
-
action:equal
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
title:'Test starts with - "^=" fro $1',
|
|
113
|
-
expected:'tab1 content',
|
|
114
|
-
result: function({$1}){
|
|
115
|
-
return $1.$('[class*="tab-content"]').innerHTML
|
|
116
|
-
},
|
|
117
|
-
action:equal
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
title:'Test ends with - "$=" fro $1',
|
|
121
|
-
expected:'tab1 content',
|
|
122
|
-
result: function({$1}){
|
|
123
|
-
return $1.$('[class*="p2 transition1"]').innerHTML
|
|
124
|
-
},
|
|
125
|
-
action:equal
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
title:'Test starts with word- "|=" fro $1',
|
|
129
|
-
expected:'css-tabs',
|
|
130
|
-
result: function({$1}){
|
|
131
|
-
return $1.$('[name|="css"]').attribs.name
|
|
132
|
-
},
|
|
133
|
-
action:equal
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
title:'Test includes word "~=" fro $1',
|
|
137
|
-
expected:true,
|
|
138
|
-
result: function({$1}){
|
|
139
|
-
return $1.$('[class~="bgc-smoke"]').classList.includes('bgc-smoke')
|
|
140
|
-
},
|
|
141
|
-
action:equal
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
title:'Test includes - "*=" fro $2',
|
|
145
|
-
expected:'w3schools.com Home',
|
|
146
|
-
result: function({$2}){
|
|
147
|
-
return $2.$('[title*=".com"]').attribs.title
|
|
148
|
-
},
|
|
149
|
-
action:equal
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
title:'Test starts with - "^=" fro $2',
|
|
153
|
-
expected:'w3-right w3-hide-small',
|
|
154
|
-
result: function({$2}){
|
|
155
|
-
return $2.$('[class^="w3-right"]').attribs.class
|
|
156
|
-
},
|
|
157
|
-
action:equal
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
title:'Test ends with - "$=" fro $2',
|
|
161
|
-
expected:'w3schools.com Home',
|
|
162
|
-
result: function({$2}){
|
|
163
|
-
return $2.$('[title$="Home"]').attribs.title
|
|
164
|
-
},
|
|
165
|
-
action:equal
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
title:'Test starts with word- "|=" fro $2',
|
|
169
|
-
expected:'en-US',
|
|
170
|
-
result: function({$2}){
|
|
171
|
-
return $2.$('[lang|="en"]').attribs.lang
|
|
172
|
-
},
|
|
173
|
-
action:equal
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
title:'Test includes word "~=" fro $2',
|
|
177
|
-
expected:'og:image:width',
|
|
178
|
-
result: function({$2}){
|
|
179
|
-
return $2.$('[property~="width"]').attribs.property
|
|
180
|
-
},
|
|
181
|
-
action:equal
|
|
182
|
-
},
|
|
183
|
-
{title:'Few selectors test for single'},
|
|
184
|
-
{
|
|
185
|
-
title:'tag and attribute $1',
|
|
186
|
-
expected:'tab1',
|
|
187
|
-
result:async function({$1}){
|
|
188
|
-
return $1.$('input[checked]').id
|
|
189
|
-
},
|
|
190
|
-
action:equal
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
title:'parent tag and attribute $1',
|
|
194
|
-
expected:'tab1',
|
|
195
|
-
result:async function({$1}){
|
|
196
|
-
return $1.$('div.tabs>input[checked]').id
|
|
197
|
-
},
|
|
198
|
-
action:equal
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
title:'parent and next $1',
|
|
202
|
-
expected:'tab2',
|
|
203
|
-
result:async function({$1}){
|
|
204
|
-
return $1.$('div.tabs>input[checked]+input').id
|
|
205
|
-
},
|
|
206
|
-
action:equal
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
title:'ancestor $1',
|
|
210
|
-
expected:true,
|
|
211
|
-
result:async function({$1}){
|
|
212
|
-
return $1.$('body [onclick*="Hello world"]').attribs.onclick.includes('this.innerHTML')
|
|
213
|
-
},
|
|
214
|
-
action:equal
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
title:'ancestor, parent and (~) $1',
|
|
218
|
-
expected:'tab3',
|
|
219
|
-
result:async function({$1}){
|
|
220
|
-
return $1.$('[checked]~#tab3').id
|
|
221
|
-
},
|
|
222
|
-
action:equal
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
title:'inner',
|
|
226
|
-
expected:'tab1 content',
|
|
227
|
-
result:async function({$1}){
|
|
228
|
-
return $1.$('[inner*="content"]').innerHTML
|
|
229
|
-
},
|
|
230
|
-
action:equal
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
title:'tag and attribute $2',
|
|
234
|
-
expected:'runbtn',
|
|
235
|
-
result:async function({$2}){
|
|
236
|
-
return $2.$('button[onclick]').id
|
|
237
|
-
},
|
|
238
|
-
action:equal
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
title:'parent tag and attribute $2',
|
|
242
|
-
expected:'×',
|
|
243
|
-
result:async function({$2}){
|
|
244
|
-
return $2.$('#container>div>span[title="Close Menu"]').innerHTML
|
|
245
|
-
},
|
|
246
|
-
action:equal
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
title:'parent and next $2',
|
|
250
|
-
expected:'w3-bar-block',
|
|
251
|
-
result:async function({$2}){
|
|
252
|
-
return $2.$('#container>div>span[title="Close Menu"]+div').attribs.class
|
|
253
|
-
},
|
|
254
|
-
action:equal
|
|
255
|
-
},
|
|
256
|
-
{
|
|
257
|
-
title:'ancestor $2',
|
|
258
|
-
expected:'Change Orientation',
|
|
259
|
-
result:async function({$2}){
|
|
260
|
-
return $2.$('#container a span').innerHTML
|
|
261
|
-
},
|
|
262
|
-
action:equal
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
title:'ancestor, parent and (~) $2',
|
|
266
|
-
expected:'Change Orientation',
|
|
267
|
-
result:async function({$2}){
|
|
268
|
-
return $2.$('#container a>i~span').innerHTML
|
|
269
|
-
},
|
|
270
|
-
action:equal
|
|
271
|
-
},
|
|
272
|
-
{
|
|
273
|
-
title:'inner',
|
|
274
|
-
expected:'Privacy policy',
|
|
275
|
-
result:async function({$2}){
|
|
276
|
-
return $2.$('[inner*="Privacy"]').innerHTML
|
|
277
|
-
},
|
|
278
|
-
action:equal
|
|
279
|
-
},
|
|
280
|
-
{title:'Select collection'},
|
|
281
|
-
{
|
|
282
|
-
title:'Select few elements (input) $1',
|
|
283
|
-
expected:3,
|
|
284
|
-
result:async function({$1}){
|
|
285
|
-
return $1.$$('input').length
|
|
286
|
-
},
|
|
287
|
-
action:equal
|
|
288
|
-
},
|
|
289
|
-
{
|
|
290
|
-
title:'Select few elements ([inner*=test]) $1',
|
|
291
|
-
expected:3,
|
|
292
|
-
result:async function({$1}){
|
|
293
|
-
return $1.$$('[inner*=test]').length
|
|
294
|
-
},
|
|
295
|
-
action:equal
|
|
296
|
-
},
|
|
297
|
-
{
|
|
298
|
-
title:'Select few elements (.transition1) $1',
|
|
299
|
-
expected:6,
|
|
300
|
-
result:async function({$1}){
|
|
301
|
-
return $1.$$('.transition1').length
|
|
302
|
-
},
|
|
303
|
-
action:equal
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
title:'Select few elements (div>.transition1) $1',
|
|
307
|
-
expected:3,
|
|
308
|
-
result:async function({$1}){
|
|
309
|
-
return $1.$$('div>.transition1').length
|
|
310
|
-
},
|
|
311
|
-
action:equal
|
|
312
|
-
},
|
|
313
|
-
{
|
|
314
|
-
title:'Select few elements (.col5>input[checked][name^=css][type]) $1',
|
|
315
|
-
expected:1,
|
|
316
|
-
result:async function({$1}){
|
|
317
|
-
return $1.$$('.col5>input[checked][name^=css][type]').length
|
|
318
|
-
},
|
|
319
|
-
action:equal
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
title:'Select few elements (.col5 label[for^="tab"]) $1',
|
|
323
|
-
expected:3,
|
|
324
|
-
result:async function({$1}){
|
|
325
|
-
return $1.$$('.col5 label[for^="tab"]').length
|
|
326
|
-
},
|
|
327
|
-
action:equal
|
|
328
|
-
},
|
|
329
|
-
{
|
|
330
|
-
title:'Select few elements (.w3-button) $2',
|
|
331
|
-
expected:12,
|
|
332
|
-
result:async function({$2}){
|
|
333
|
-
return $2.$$('.w3-button').length
|
|
334
|
-
},
|
|
335
|
-
action:equal
|
|
336
|
-
},
|
|
337
|
-
{
|
|
338
|
-
title:'Select few elements (.w3-button) $2',
|
|
339
|
-
expected:1,
|
|
340
|
-
result:async function({$2}){
|
|
341
|
-
return $2.$$('.w3-button>img').length
|
|
342
|
-
},
|
|
343
|
-
action:equal
|
|
344
|
-
},
|
|
345
|
-
{
|
|
346
|
-
title:'Select few elements (.w3-button>img+span) $2',
|
|
347
|
-
expected:'Go to Spaces',
|
|
348
|
-
result:async function({$2}){
|
|
349
|
-
return $2.$$('.w3-button>img+span')[0].innerHTML
|
|
350
|
-
},
|
|
351
|
-
action:equal
|
|
352
|
-
},
|
|
353
|
-
{
|
|
354
|
-
title:'Select few elements (#container div) $2',
|
|
355
|
-
expected:30,
|
|
356
|
-
result:async function({$2}){
|
|
357
|
-
return $2.$$('#container div').length
|
|
358
|
-
},
|
|
359
|
-
action:equal
|
|
360
|
-
},
|
|
361
|
-
{
|
|
362
|
-
title:'Select few elements (#container div) $2',
|
|
363
|
-
expected:4,
|
|
364
|
-
result:async function({$2}){
|
|
365
|
-
return $2.$$('#container>div').length
|
|
366
|
-
},
|
|
367
|
-
action:equal
|
|
368
|
-
},
|
|
369
|
-
{title:'Few selectors'},
|
|
370
|
-
{
|
|
371
|
-
title:'Select few elements (.col5 label[for^="tab"],input[checked]) $1',
|
|
372
|
-
expected:4,
|
|
373
|
-
result:async function({$1}){
|
|
374
|
-
return $1.$$('.col5 label[for^="tab"],input[checked]').length
|
|
375
|
-
},
|
|
376
|
-
action:equal
|
|
377
|
-
},
|
|
378
|
-
{
|
|
379
|
-
title:'Select few elements ([style],[onclick]) $1',
|
|
380
|
-
expected:7,
|
|
381
|
-
result:async function({$1}){
|
|
382
|
-
return $1.$$('[style],[onclick],[name]').length
|
|
383
|
-
},
|
|
384
|
-
action:equal
|
|
385
|
-
},
|
|
386
|
-
{
|
|
387
|
-
title:'Select few elements (#container a[title]) $2',
|
|
388
|
-
expected:4,
|
|
389
|
-
result:async function({$2}){
|
|
390
|
-
return $2.$$('#container a[title]').length
|
|
391
|
-
},
|
|
392
|
-
action:equal
|
|
393
|
-
},
|
|
394
|
-
{
|
|
395
|
-
title:'Select few elements (div,span) $2',
|
|
396
|
-
expected:165,
|
|
397
|
-
result:async function({$2}){
|
|
398
|
-
return $2.$$('div,span').length
|
|
399
|
-
},
|
|
400
|
-
action:equal
|
|
401
|
-
},
|
|
402
|
-
{
|
|
403
|
-
title:'Select few elements (meta[property^="og"],meta[content^="width"]) $2',
|
|
404
|
-
expected:8,
|
|
405
|
-
result:async function({$2}){
|
|
406
|
-
return $2.$$('meta[property^="og"],meta[content^="width"]').length
|
|
407
|
-
},
|
|
408
|
-
action:equal
|
|
409
|
-
},
|
|
410
|
-
])
|