als-document 0.5.0 → 0.6.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/readme.md CHANGED
@@ -1,78 +1,135 @@
1
- # Als-document
1
+ # als-document
2
2
 
3
- Builded from scatch and tested.
4
- All tested with als-test.
3
+ Build virtual dom from string and manage it, similar you do it on browser.
4
+ Now it's fast and simple!
5
5
 
6
- Als-document is a library which includes 3 instrements:
6
+ ## About
7
+ Als-document is a library which includes 4 instruments:
7
8
  * Html parser - for fast html string parsing and building dom tree
8
- * Html query parser - for destructing css/html query to selectors inside array of objects
9
+ * Html query parser - for destructing css/html query to selectors to array of objects
9
10
  * Html selector - for selecting elements with css/html query inside parsed dom tree
11
+ * Document - extending html selector with managing tools
10
12
 
11
- - [Als-document](#als-document)
12
- - [Selector](#selector)
13
- - [Basics](#basics)
14
- - [FrontEnd usage](#frontend-usage)
15
- - [BackEnd usage](#backend-usage)
13
+
14
+ - [als-document](#als-document)
15
+ - [About](#about)
16
+ - [Basics](#basics)
17
+ - [Example](#example)
18
+ - [Element properties and methods](#element-properties-and-methods)
19
+ - [Selecting elements](#selecting-elements)
16
20
  - [Extra abilities](#extra-abilities)
17
- - [HtmlParser](#htmlparser)
21
+ - [Add/rearrange/remove element](#addrearrangeremove-element)
22
+ - [Example](#example-1)
23
+ - [Changing attributes](#changing-attributes)
24
+ - [Inline style](#inline-style)
25
+ - [Classlist](#classlist)
26
+ - [HtmlParser documentation](#htmlparser-documentation)
27
+ - [new in 0.6](#new-in-06)
18
28
  - [Syntax](#syntax)
19
29
  - [Frontend example](#frontend-example)
20
30
  - [Backend example](#backend-example)
21
- - [Query](#query)
31
+ - [Query documentation](#query-documentation)
22
32
  - [Syntax](#syntax-1)
23
- - [Example](#example)
33
+ - [Example](#example-2)
24
34
  - [Attribs and check function](#attribs-and-check-function)
25
35
 
26
36
 
27
- ## Selector
28
37
 
29
- Selector is a class which uses HtmlParser for parsing html and Query for parsing html/css query.
30
- Everything does Query class support, can be selected (so far available all, except pseudos).
31
- Selector can be used on frontend and on backend.
38
+ ## Basics
39
+ You can use als-document on node.js and in browser.
32
40
 
41
+ For using in browser, just include:
42
+ ``node_modules/als-document/document.js``
43
+ or ``node_modules/als-document/document.min.js``.
33
44
 
34
- ### Basics
45
+ ```html
46
+ <script src="node_modules/als-document/document.min.js"></script>
47
+ ```
35
48
 
36
- **Syntax**
49
+ For using on backend, require from ``als-document``.
37
50
  ```javascript
38
- let doc = new HtmlSelector(htmlString:string):instanceof HtmlSelector
39
- doc.$(query:string):object | null
40
- doc.$$(query:string):array
41
- doc.$(query:string).$(query:qeury).$$(query:qeury)
51
+ let {HtmlSelector,HtmlParser,Query,Document} = require('als-document')
42
52
  ```
43
53
 
44
- ``query`` - html/css query for selecting
45
- ``$`` - method return first element or null
46
- ``$$`` - return collection or empty array
47
- Each element, has ``$`` and ``$$`` methods for selecting descendants
54
+ Basicly, you need only Document. Because Document uses all the rest. But you can use any class separatly too.
48
55
 
49
56
 
50
- **Example**
57
+ ### Example
51
58
  ```javascript
52
- let doc = new HtmlSelector(htmlString)
53
- let body = doc.$('body') // querySelector('body'):element|null
54
- let divs = body.$$('div') // body.querySelectorAll('div'):array
55
- console.log(divs)
56
- ```
57
-
58
-
59
- #### FrontEnd usage
60
- ```html
61
- <script src="/node_modules/als-document/document.js"></script>
62
- <script>
63
- let htmlText = `
64
- <div>
65
- <span>Another one</span>
66
- <div>Some text</div>
67
- </div>
59
+ let htmlText = /*html*/`
60
+ <!DOCTYPE html>
61
+ <html lang="en">
62
+ <head>
63
+ <title>Test document</title>
64
+ </head>
65
+ <body>
66
+ <div id="test">Hello world!</div>
67
+ </body>
68
+ </html>
68
69
  `
69
- let doc = new HtmlSelector(htmlText)
70
- let span = doc.$('div>span')
71
- </script>
70
+ let doc = new Document(htmlText)
71
+ let body = doc.$('body')
72
+ let div = body.$('#test')
73
+ console.log(div.innerHTML) // Hello world!
74
+ div.before = '<div id="test1">Another div</div>'
75
+ console.log(div.prev.id) // test1
72
76
  ```
73
77
 
74
78
 
75
- #### BackEnd usage
79
+ ## Element properties and methods
80
+ Each element (except root and text elements, which has no all) has:
81
+ * Variables
82
+ * ``attribs`` - element's attributes as object
83
+ * ``parent`` - parent element
84
+ * ``children`` - array of children include text nodes
85
+ * ``type`` - tag or text or root
86
+ * ``classList`` - array with classes and methods for managing classList
87
+ * ``add`` - adds new class to classList
88
+ * ``remove`` - removes class from classList
89
+ * ``toggle`` - toggle class inside classList
90
+ * ``index`` - start index of element inside elements list
91
+ * ``endIndex`` - end index of element inside elements list
92
+ * ``id`` - getter for element's id (return id or null)
93
+ * ``level`` - level in dom tree
94
+ * ``text`` - parsed text for tag and for text element
95
+ * ``tab`` - space for formating innerHTML. default:tab= ' '
96
+ * ``n`` - separate elements in innerHTML by n. default n = '\n'
97
+ * ``style`` - Proxy array of styles with camelCase property name
98
+ * getters
99
+ * ``innerText`` - concats all children's text together | ''
100
+ * ``innerHTML`` - return innerHTML for element
101
+ * ``outerHTML`` - return outerHTML for element
102
+ * ``ancestors`` - return array of ancestors
103
+ * ``root`` - root element
104
+ * ``html`` - HtmlParser object for all elements
105
+ * ``$elements`` - all parsed elements
106
+ * ``next`` - next element or null
107
+ * ``prev`` - previous element or null
108
+ * ``childIndex`` - index of child in parent.children
109
+ * ``id`` - getting id of element
110
+ * Setters
111
+ * ``before`` - adding new/existing element before the element
112
+ * ``after`` - adding new/existing element after the element
113
+ * ``first`` - adding new/existing element as first child of the element
114
+ * ``last`` - adding new/existing element as last child of the element
115
+ * Methods
116
+ * ``getAttribute(name)`` - return value of attribute or null
117
+ * ``attr(name,value``) - get,set,remove attribute
118
+ * ``remove()`` - removing element
119
+ * ``insert(element,position)`` - inserting/rearanging element
120
+ * ``$`` - for selecting any descendant of the element
121
+ * ``$$`` - for selecting collection of descendants of the element
122
+
123
+
124
+ ## Selecting elements
125
+ For select elements inside virtual dom, you can use ``HtmlSelector`` or ``Document``.
126
+ If you need only selecting, use ``HtmlSelector``, otherwise use ``Document``.
127
+ Document is extended HtmlSelector.
128
+
129
+ two methods:
130
+ * ``$`` - for selecting first element
131
+ * ``$$`` - for selecting collection
132
+
76
133
  ```javascript
77
134
  let {HtmlSelector} = require('als-document')
78
135
  let htmlText = `
@@ -83,12 +140,16 @@ let htmlText = `
83
140
  `
84
141
  let doc = new HtmlSelector(htmlText)
85
142
  let span = doc.$('div>span')
143
+ let divs = doc.$$('div')
86
144
  ```
87
145
 
146
+ So far, available almost all possible selectors, without pseudo class and pseudo element selector.
147
+ For example, you can select ``div>.some span+input.some-class[checked]``.
148
+ But you can't select ``input:checked``.
88
149
 
89
150
  ### Extra abilities
90
151
  Usualy, browser selector can select by tag name,class, attribute or id.
91
- HtmlSelector, has extra selecting options, since id,style,class,events and innerHTML - can be selected as attribute.
152
+ HtmlSelector/Document, has extra selecting options, since id,style,class,events and innerHTML - can be selected as attribute.
92
153
 
93
154
  For example you can do those things:
94
155
  ```javascript
@@ -98,13 +159,113 @@ doc.$('[class*="btn"][class*="danger"]') //class includes "btn" and "danger"
98
159
  doc.$('[id^="tab"]') //id starts with "tab-"
99
160
  doc.$('[inner$="00"]') //innerText ends with ".00"
100
161
  ```
101
- ## HtmlParser
162
+
163
+
164
+ ## Add/rearrange/remove element
165
+ Document has methods and setters for changing virtual dom. Here are the methods:
166
+
167
+ ```javascript
168
+ let newElement = string || object // html text or another selected element
169
+ let position = number [0,1,2,3] // 0-before element,1-first child,2-last-child,3-after element
170
+ element.insert(newElement,position):object // insert new element or rearange existing element
171
+ element.remove() // removig existing element from dom tree
172
+ element.before = newElement // adding new element before the element
173
+ element.after = newElement // adding new element after the element
174
+ element.first = newElement // adding new element as first child of element
175
+ element.last = newElement // adding new element as last child of element
176
+ ```
177
+
178
+ > before,after,first,last are getters which uses insert method.
179
+
180
+
181
+ ### Example
182
+ ```javascript
183
+ // create new element and insert it before first div
184
+ doc.$('div').insert('<div>new element</div>',0)
185
+ doc.$('div').before = '<div>new element</div>'
186
+ // Rearange div#some as first child for first div
187
+ doc.$('div').insert(doc.$('div#some'),1)
188
+ doc.$('div').first = doc.$('div#some')
189
+ ```
190
+
191
+
192
+ ## Changing attributes
193
+ There are few ways to get element's attributes:
194
+ ```javascript
195
+ doc.$('div').attribs.name // available on HtmlParser and Document
196
+ doc.$('div').getAttribute(name) // available on HtmlParser and Document
197
+ doc.$('div').attr(name) // not available on HtmlParser
198
+ ```
199
+
200
+ For setting or removing attributes, use attr method (available only in Document).
201
+ Here the syntax:
202
+ ```javascript
203
+ doc.$('input').attr('checked','') // add checked attribute
204
+ doc.$('div#some').attr('title','Some title') // set title="Some title"
205
+ doc.$('input').attr('disabled',null) // remove disabled attribute
206
+ ```
207
+
208
+ If you changing the class attribute with attr, classList changing too.
209
+
210
+ > Don't remove or change style and id with attr
211
+ > Dont't remove class with attr
212
+
213
+ element.id has getter and setter
214
+ * getter - return id | null
215
+ * setter - changing id in element.attribs.id
216
+
217
+
218
+ ### Inline style
219
+ ``element.style`` is a Proxy object, which means you can't get all style properties as object.
220
+ To get styles object use ``element.style.target``.
221
+
222
+ Syntax:
223
+ ```javascript
224
+ let element = doc.$('[style]')
225
+ // Get style object with camelCase property names
226
+ element.style.target
227
+ // Get value for specific style property
228
+ element.style.backgroundColor // value || undefined
229
+ // Set new value for existing or for new property
230
+ element.style.backgroundColor = 'blue'
231
+ // Remove property from style and from attribs.style
232
+ delete element.style.backgroundColor
233
+ ```
234
+
235
+
236
+ ### Classlist
237
+ ``ClassList`` is array with existing classes splited from ``attribs.class``.
238
+
239
+ Syntax:
240
+ ```javascript
241
+ let element = doc.$('[class]')
242
+ // The folowing methods, changing element.attribs.class too.
243
+ element.add(newClassName)
244
+ element.remove(existingClassName)
245
+ element.toggle(className)
246
+ ```
247
+
248
+
249
+ ## HtmlParser documentation
102
250
 
103
251
  HtmlParser is a class which build dom tree from html string.
104
252
 
105
253
  * HtmlParser removes all html comments and they not included in dom tree.
106
- * Contrary to regular dom, attribute includes class,id and style as attribute in addition to classList, id and style(as array).
107
-
254
+ * Contrary to regular dom, attribute includes class,id and style as attribute in addition to classList, id and style(as array) inside element's object.
255
+
256
+ ### new in 0.6
257
+ * fixed
258
+ * bug with text for elements with events - solved
259
+ * elements for single tag - solved
260
+ * Updates
261
+ * added root getter to each element
262
+ * added $elements getter to each element
263
+ * next and prev,childIndex now getters
264
+ * added childIndex,next,prev,ancestors,parent to text element
265
+ * root has innerHTML
266
+ * option to format innerHTML
267
+ * by default element.tab = ' '
268
+ * by default element.n = '\n'
108
269
 
109
270
  ### Syntax
110
271
 
@@ -119,8 +280,6 @@ HtmlParser.parse(html):object // parsed.root
119
280
  Each element, except root and text elements has:
120
281
  * attribs - element's attributes
121
282
  * parent - parent element
122
- * next - next element or null
123
- * prev - previous element or null
124
283
  * children - array of children include text nodes
125
284
  * type - tag or text or root
126
285
  * classList - array with classes
@@ -129,10 +288,18 @@ Each element, except root and text elements has:
129
288
  * endIndex - end index of element inside elements list
130
289
  * level - level in dom tree
131
290
  * text - parsed text for tag and for text element
132
- * innerText:getter - concats all children's text together | ''
133
- * innerHTML:getter - return innerHTML for element
134
- * outerHTML:getter - return outerHTML for element
135
- * ancestors:getter - return array of ancestors
291
+ * tab - space for formating innerHTML. default:tab= ' '
292
+ * n - separate elements in innerHTML by n. default n = '\n'
293
+ * getters
294
+ * innerText - concats all children's text together | ''
295
+ * innerHTML - return innerHTML for element
296
+ * outerHTML - return outerHTML for element
297
+ * ancestors - return array of ancestors
298
+ * root - root element
299
+ * added $elements - all parsed elements
300
+ * next - next element or null
301
+ * prev - previous element or null
302
+ * childIndex - index of child in parent.children
136
303
  * getAttribute(name) - return value of attribute or null
137
304
  * style:[] - array of styles with camelCase property name
138
305
 
@@ -141,6 +308,7 @@ Example for parsed.document
141
308
  ```javascript
142
309
  {
143
310
  type:'root',
311
+ ...,
144
312
  children:[
145
313
  {
146
314
  attribs: {},
@@ -194,23 +362,25 @@ Example for parsed.document
194
362
 
195
363
 
196
364
  ### Frontend example
365
+ You can use:
366
+ * node_modules/als-document/document.js - original file
367
+ * node_modules/als-document/document.min.js - minimized file
197
368
 
198
369
  ```html
199
- <script src="/node_modules/als-document/parser/parser.js"></script>
370
+ <script src="node_modules/als-document/document.min.js"></script>
200
371
  <script>
201
- let result = new HtmlParser(htmlString)
202
- console.log(result.root)
203
-
204
- // Or with static method
205
- console.log(HtmlParser.parse(html))
372
+ let result = new HtmlParser(htmlString)
373
+ console.log(result.root)
206
374
 
375
+ // Or with static method
376
+ console.log(HtmlParser.parse(html))
207
377
  </script>
208
378
  ```
209
379
 
210
380
  ### Backend example
211
381
 
212
382
  ```javascript
213
- const {HtmlParser} = require('als-htmlparser')
383
+ const {HtmlParser} = require('als-document')
214
384
  let result = new HtmlParser(htmlString)
215
385
  console.log(result.root)
216
386
 
@@ -219,15 +389,18 @@ console.log(HtmlParser.parse(html))
219
389
  ```
220
390
 
221
391
 
222
- ## Query
223
- Query is a class for parsing conditions inside html query. Query not supporting pseudo selectors so far.
392
+ ## Query documentation
393
+ Query is a class for parsing selectors inside html query. Query not supporting pseudo selectors so far.
224
394
  You can use Query on frontend and on backend.
225
395
 
226
396
  Query can be used on fronten and on backend.
397
+ You can use:
398
+ * node_modules/als-document/document.js - original file
399
+ * node_modules/als-document/document.min.js - minimized file
227
400
 
228
401
  Frontend:
229
402
  ```html
230
- <script src="/node_modules/als-document/query/query.js"></script>
403
+ <script src="node_modules/als-document/document.min.js"></script>
231
404
  ```
232
405
 
233
406
  Backend:
@@ -350,3 +523,4 @@ let s = Query.get('[test^="some"]')[0]
350
523
  console.log(s.attribs[0].check('some value test')) // true
351
524
  ```
352
525
 
526
+
@@ -1,20 +1,20 @@
1
+ let Query = require('../query/query')
2
+ let HtmlParser = require("../parser/parser")
3
+
1
4
  class HtmlSelector {
2
5
  constructor(html) {
3
6
  if(typeof html == 'string') {
4
- html = new HtmlParser(html)
5
- this.html = html
6
- this.elements = html.elements
7
- this.makeSelectable()
7
+ this.html = new HtmlParser(html)
8
+ this.elements.forEach((element,i) => {this.makeSelectable(element)});
8
9
  } else console.log('Parameter is not string')
9
10
  }
10
-
11
- makeSelectable() {
12
- this.elements.forEach(element => {
13
- if(element.type == 'tag' && element.status !== 'close') {
14
- element.$$ = (query) => this.$$(query,element.index,element.endIndex)
15
- element.$ = (query) => this.$(query,element.index,element.endIndex)
16
- }
17
- })
11
+ get elements() {return this.html.elements}
12
+
13
+ makeSelectable(element) {
14
+ if(element.type == 'tag' && element.status !== 'close') {
15
+ element.$$ = (query) => this.$$(query,element.index,element.endIndex)
16
+ element.$ = (query) => this.$(query,element.index,element.endIndex)
17
+ }
18
18
  }
19
19
 
20
20
  $(query,start=0,end=this.elements.length) {
@@ -120,6 +120,7 @@ class HtmlSelector {
120
120
  if(passedTests == attribs.length) return true
121
121
  else return false
122
122
  }
123
+
123
124
  }
124
125
 
125
- try {module.exports = HtmlSelector} catch{}
126
+ module.exports = HtmlSelector
package/selector/test.js CHANGED
@@ -1,6 +1,6 @@
1
1
  let Test = require('als-test')
2
2
  // const HtmlSelector = require('./selector')
3
- const {HtmlSelector} = require('../build/document')
3
+ const {HtmlSelector} = require('als-document')
4
4
  let {equal,greater,smaller,$greater, $smaller} = Test
5
5
 
6
6
  module.exports = new Test('Selector tests',[
package/test/test.js CHANGED
@@ -4,12 +4,14 @@ let Test = require('als-test')
4
4
  let parser = require('../parser/test')
5
5
  let query = require('../query/test')
6
6
  let selector = require('../selector/test')
7
+ let document = require('../document/test')
7
8
 
8
9
  async function run() {
9
10
  await Test.run('Document tests',[
10
11
  parser,
11
12
  query,
12
- selector
13
+ selector,
14
+ document
13
15
  ],{html1,html2})
14
16
 
15
17
  Test.summary()
package/parser/readme.md DELETED
@@ -1,121 +0,0 @@
1
- ## HtmlParser
2
-
3
- HtmlParser is a class which build dom tree from html string.
4
-
5
- * HtmlParser removes all html comments and they not included in dom tree.
6
- * Contrary to regular dom, attribute includes class,id and style as attribute in addition to classList, id and style(as array).
7
-
8
-
9
- ### Syntax
10
-
11
- ```javascript
12
- let parsed = new HtmlParser(htmlString:string):instanceof HtmlParser
13
- parsed.root : circular object
14
-
15
- // static method
16
- HtmlParser.parse(html):object // parsed.root
17
- ```
18
-
19
- Each element, except root and text elements has:
20
- * attribs - element's attributes
21
- * parent - parent element
22
- * next - next element or null
23
- * prev - previous element or null
24
- * children - array of children include text nodes
25
- * type - tag or text or root
26
- * classList - array with classes
27
- * index - start index of element inside elements list
28
- * id - element's id or null
29
- * endIndex - end index of element inside elements list
30
- * level - level in dom tree
31
- * text - parsed text for tag and for text element
32
- * innerText:getter - concats all children's text together | ''
33
- * innerHTML:getter - return innerHTML for element
34
- * outerHTML:getter - return outerHTML for element
35
- * ancestors:getter - return array of ancestors
36
- * getAttribute(name) - return value of attribute or null
37
- * style:[] - array of styles with camelCase property name
38
-
39
- Example for parsed.document
40
-
41
- ```javascript
42
- {
43
- type:'root',
44
- children:[
45
- {
46
- attribs: {},
47
- index: 0,
48
- prev:null,
49
- next:{...}
50
- tag: "!DOCTYPE html",
51
- type: "tag",
52
- ...
53
- },
54
- {
55
- attribs: {lang:'en'},
56
- prev:{...},
57
- next:null,
58
- classList:[],
59
- children:[
60
- {
61
- attribs: {},
62
- children:[...]
63
- prev:null,
64
- next:{...}
65
- classList:[],
66
- index: 2,
67
- tag: "head",
68
- parent:{tag:'html',...} // reference to parent
69
- type: "tag",
70
- ...
71
- },
72
- {
73
- attribs: {},
74
- children:[...]
75
- index: 10,
76
- prev:{...},
77
- next:null,
78
- classList:[],
79
- tag: "body",
80
- parent:{tag:'html',...} // reference to parent
81
- type: "tag",
82
- ...
83
- },
84
- ]
85
- index: 1,
86
- tag: "html",
87
- parent:{type:'root',...} // reference to parent
88
- type: "tag",
89
- ...
90
- }
91
- ]
92
- }
93
- ```
94
-
95
-
96
- ### Frontend example
97
-
98
- ```html
99
- <script src="/node_modules/als-document/parser/parser.js"></script>
100
- <script>
101
- let result = new HtmlParser(htmlString)
102
- console.log(result.root)
103
-
104
- // Or with static method
105
- console.log(HtmlParser.parse(html))
106
-
107
- </script>
108
- ```
109
-
110
- ### Backend example
111
-
112
- ```javascript
113
- const {HtmlParser} = require('als-htmlparser')
114
- let result = new HtmlParser(htmlString)
115
- console.log(result.root)
116
-
117
- // Or with static method
118
- console.log(HtmlParser.parse(html))
119
- ```
120
-
121
-
@@ -1,74 +0,0 @@
1
- ## Selector
2
-
3
- Selector is a class which uses HtmlParser for parsing html and Query for parsing html/css query.
4
- Everything does Query class support, can be selected (so far available all, except pseudos).
5
- Selector can be used on frontend and on backend.
6
-
7
-
8
- ### Basics
9
-
10
- **Syntax**
11
- ```javascript
12
- let doc = new HtmlSelector(htmlString:string):instanceof HtmlSelector
13
- doc.$(query:string):object | null
14
- doc.$$(query:string):array
15
- doc.$(query:string).$(query:qeury).$$(query:qeury)
16
- ```
17
-
18
- ``query`` - html/css query for selecting
19
- ``$`` - method return first element or null
20
- ``$$`` - return collection or empty array
21
- Each element, has ``$`` and ``$$`` methods for selecting descendants
22
-
23
-
24
- **Example**
25
- ```javascript
26
- let doc = new HtmlSelector(htmlString)
27
- let body = doc.$('body') // querySelector('body'):element|null
28
- let divs = body.$$('div') // body.querySelectorAll('div'):array
29
- console.log(divs)
30
- ```
31
-
32
-
33
- #### FrontEnd usage
34
- ```html
35
- <script src="/node_modules/als-document/document.js"></script>
36
- <script>
37
- let htmlText = `
38
- <div>
39
- <span>Another one</span>
40
- <div>Some text</div>
41
- </div>
42
- `
43
- let doc = new HtmlSelector(htmlText)
44
- let span = doc.$('div>span')
45
- </script>
46
- ```
47
-
48
-
49
- #### BackEnd usage
50
- ```javascript
51
- let {HtmlSelector} = require('als-document')
52
- let htmlText = `
53
- <div>
54
- <span>Another one</span>
55
- <div>Some text</div>
56
- </div>
57
- `
58
- let doc = new HtmlSelector(htmlText)
59
- let span = doc.$('div>span')
60
- ```
61
-
62
-
63
- ### Extra abilities
64
- Usualy, browser selector can select by tag name,class, attribute or id.
65
- HtmlSelector, has extra selecting options, since id,style,class,events and innerHTML - can be selected as attribute.
66
-
67
- For example you can do those things:
68
- ```javascript
69
- doc.$('[style*="display"]') //style includes "display"
70
- doc.$('[onclick*="console.log"]') //event includes "console"
71
- doc.$('[class*="btn"][class*="danger"]') //class includes "btn" and "danger"
72
- doc.$('[id^="tab"]') //id starts with "tab-"
73
- doc.$('[inner$="00"]') //innerText ends with ".00"
74
- ```