xml-twig 1.7.12 → 1.7.13

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.
Files changed (3) hide show
  1. package/doc/twig.md +83 -83
  2. package/package.json +1 -1
  3. package/twig.js +42 -42
package/doc/twig.md CHANGED
@@ -33,7 +33,7 @@
33
33
  ## Functions
34
34
 
35
35
  <dl>
36
- <dt><a href="#createParser">createParser(handler, [options])</a> ⇒ <code><a href="#Parser">Parser</a></code></dt>
36
+ <dt><a href="#createParser">createParser(handler, options)</a> ⇒ <code><a href="#Parser">Parser</a></code></dt>
37
37
  <dd><p>Create a new Twig parser</p>
38
38
  </dd>
39
39
  <dt><a href="#onStart">onStart(parser, binds, node, attrs)</a></dt>
@@ -120,7 +120,7 @@ You can specify a <code>function</code> or a <code>event</code> name</p>
120
120
 
121
121
  * [Twig](#Twig)
122
122
  * [new Twig()](#new_Twig_new)
123
- * [new Twig(parser, name, [parent], [attributes], [index])](#new_Twig_new)
123
+ * [new Twig(parser, name, parent, attributes, index)](#new_Twig_new)
124
124
  * [.attributes](#Twig+attributes) : <code>object</code> ℗
125
125
  * [.text](#Twig+text) : <code>string</code> \| <code>number</code> ℗
126
126
  * [.name](#Twig+name) : <code>string</code> ℗
@@ -176,8 +176,8 @@ You can specify a <code>function</code> or a <code>event</code> name</p>
176
176
  * [.addElement](#Twig+addElement) ⇒ [<code>Twig</code>](#Twig)
177
177
  * [.delete](#Twig+delete)
178
178
  * [.setRoot(name)](#Twig+setRoot) ℗
179
- * [.filterElements(elements, [condition])](#Twig+filterElements) ⇒ [<code>Array.&lt;Twig&gt;</code>](#Twig)
180
- * [.testElement(element, [condition])](#Twig+testElement) ⇒ <code>boolean</code>
179
+ * [.filterElements(elements, condition)](#Twig+filterElements) ⇒ [<code>Array.&lt;Twig&gt;</code>](#Twig)
180
+ * [.testElement(element, condition)](#Twig+testElement) ⇒ <code>boolean</code>
181
181
 
182
182
  <a name="new_Twig_new"></a>
183
183
 
@@ -186,7 +186,7 @@ Generic class modeling a XML Node
186
186
 
187
187
  <a name="new_Twig_new"></a>
188
188
 
189
- ### new Twig(parser, name, [parent], [attributes], [index])
189
+ ### new Twig(parser, name, parent, attributes, index)
190
190
  Create a new Twig object
191
191
 
192
192
 
@@ -194,9 +194,9 @@ Create a new Twig object
194
194
  | --- | --- | --- |
195
195
  | parser | [<code>Parser</code>](#Parser) | The main parser object |
196
196
  | name | <code>string</code> | The name of the XML element |
197
- | [parent] | [<code>Twig</code>](#Twig) | The parent object |
198
- | [attributes] | <code>object</code> | Attribute object |
199
- | [index] | <code>string</code> \| <code>number</code> | Position name 'first', 'last' or the position in the current `children` array.<br>Defaults to 'last' |
197
+ | parent | [<code>Twig</code>](#Twig) | The parent object |
198
+ | attributes | <code>object</code> | Attribute object |
199
+ | index | <code>string</code> \| <code>number</code> | Position name 'first', 'last' or the position in the current `children` array.<br>Defaults to 'last' |
200
200
 
201
201
  <a name="Twig+attributes"></a>
202
202
 
@@ -255,7 +255,7 @@ Purges up to the elt element. This allows you to keep part of the tree in memory
255
255
 
256
256
  | Param | Type | Description |
257
257
  | --- | --- | --- |
258
- | [elt] | [<code>Twig</code>](#Twig) | Up to this element the tree will be purged. If `undefined` then the current element is purged (i.e. `purge()`) |
258
+ | elt | [<code>Twig</code>](#Twig) | Up to this element the tree will be purged. If `undefined` then the current element is purged (i.e. `purge()`) |
259
259
 
260
260
  <a name="Twig+escapeEntity"></a>
261
261
 
@@ -413,7 +413,7 @@ Returns attribute value or `null` if not found.<br>
413
413
 
414
414
  | Param | Type | Description |
415
415
  | --- | --- | --- |
416
- | [condition] | [<code>AttributeCondition</code>](#AttributeCondition) | Optional condition to select attribute |
416
+ | condition | [<code>AttributeCondition</code>](#AttributeCondition) | Optional condition to select attribute |
417
417
 
418
418
  <a name="Twig+attributes"></a>
419
419
 
@@ -444,8 +444,8 @@ Retrieve or update XML attribute. For update, the condition must be a string, i.
444
444
 
445
445
  | Param | Type | Description |
446
446
  | --- | --- | --- |
447
- | [condition] | [<code>AttributeCondition</code>](#AttributeCondition) | Optional condition to select attributes |
448
- | [value] | <code>string</code> \| <code>number</code> \| <code>bigint</code> \| <code>boolean</code> | New value of the attribute.<br>If `undefined` then existing attributes is returned. |
447
+ | condition | [<code>AttributeCondition</code>](#AttributeCondition) | Optional condition to select attributes |
448
+ | value | <code>string</code> \| <code>number</code> \| <code>bigint</code> \| <code>boolean</code> | New value of the attribute.<br>If `undefined` then existing attributes is returned. |
449
449
 
450
450
  **Example**
451
451
  ```js
@@ -490,7 +490,7 @@ All children, optionally matching `condition` of the current element or empty ar
490
490
 
491
491
  | Param | Type | Description |
492
492
  | --- | --- | --- |
493
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
493
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
494
494
 
495
495
  <a name="Twig+next"></a>
496
496
 
@@ -503,7 +503,7 @@ Returns the next matching element.
503
503
 
504
504
  | Param | Type | Description |
505
505
  | --- | --- | --- |
506
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
506
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
507
507
 
508
508
  <a name="Twig+previous"></a>
509
509
 
@@ -516,7 +516,7 @@ Returns the previous matching element.
516
516
 
517
517
  | Param | Type | Description |
518
518
  | --- | --- | --- |
519
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
519
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
520
520
 
521
521
  <a name="Twig+first"></a>
522
522
 
@@ -528,7 +528,7 @@ Returns the first matching element. This is usually the root element
528
528
 
529
529
  | Param | Type | Description |
530
530
  | --- | --- | --- |
531
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
531
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
532
532
 
533
533
  <a name="Twig+last"></a>
534
534
 
@@ -540,7 +540,7 @@ Returns the last matching element.
540
540
 
541
541
  | Param | Type | Description |
542
542
  | --- | --- | --- |
543
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
543
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
544
544
 
545
545
  <a name="Twig+isFirstChild"></a>
546
546
 
@@ -566,7 +566,7 @@ Returns descendants (children, grandchildren, etc.) of the current element
566
566
 
567
567
  | Param | Type | Description |
568
568
  | --- | --- | --- |
569
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
569
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
570
570
 
571
571
  <a name="Twig+descendantOrSelf"></a>
572
572
 
@@ -578,7 +578,7 @@ Returns descendants (children, grandchildren, etc.) of the current element and t
578
578
 
579
579
  | Param | Type | Description |
580
580
  | --- | --- | --- |
581
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
581
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
582
582
 
583
583
  <a name="Twig+ancestor"></a>
584
584
 
@@ -590,7 +590,7 @@ Returns ancestors (parent, grandparent, etc.) of the current element
590
590
 
591
591
  | Param | Type | Description |
592
592
  | --- | --- | --- |
593
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
593
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
594
594
 
595
595
  <a name="Twig+ancestorOrSelf"></a>
596
596
 
@@ -602,7 +602,7 @@ Returns ancestors (parent, grandparent, etc.) of the current element and the cu
602
602
 
603
603
  | Param | Type | Description |
604
604
  | --- | --- | --- |
605
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
605
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
606
606
 
607
607
  <a name="Twig+sibling"></a>
608
608
 
@@ -614,7 +614,7 @@ Returns all sibling element of the current element
614
614
 
615
615
  | Param | Type | Description |
616
616
  | --- | --- | --- |
617
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
617
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
618
618
 
619
619
  <a name="Twig+siblingOrSelf"></a>
620
620
 
@@ -626,7 +626,7 @@ Returns all sibling element of the current element and the current element itsel
626
626
 
627
627
  | Param | Type | Description |
628
628
  | --- | --- | --- |
629
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
629
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
630
630
 
631
631
  <a name="Twig+followingSibling"></a>
632
632
 
@@ -638,7 +638,7 @@ Returns all following sibling element of the current element
638
638
 
639
639
  | Param | Type | Description |
640
640
  | --- | --- | --- |
641
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
641
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
642
642
 
643
643
  <a name="Twig+precedingSibling"></a>
644
644
 
@@ -650,7 +650,7 @@ Returns all preceding sibling element of the current element
650
650
 
651
651
  | Param | Type | Description |
652
652
  | --- | --- | --- |
653
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
653
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
654
654
 
655
655
  <a name="Twig+nextSibling"></a>
656
656
 
@@ -662,7 +662,7 @@ Returns next sibling element of the current element
662
662
 
663
663
  | Param | Type | Description |
664
664
  | --- | --- | --- |
665
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
665
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
666
666
 
667
667
  <a name="Twig+prevSibling"></a>
668
668
 
@@ -674,7 +674,7 @@ Returns previous sibling element of the current element
674
674
 
675
675
  | Param | Type | Description |
676
676
  | --- | --- | --- |
677
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
677
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
678
678
 
679
679
  <a name="Twig+find"></a>
680
680
 
@@ -699,9 +699,9 @@ Add a new element in the current element
699
699
  | Param | Type | Description |
700
700
  | --- | --- | --- |
701
701
  | name | <code>string</code> | The tag name |
702
- | [text] | <code>string</code> | Text of the element |
703
- | [attributes] | <code>object</code> | Element attributes |
704
- | [position] | <code>name</code> \| <code>number</code> | Position name 'first', 'last' or the position in the `children` |
702
+ | text | <code>string</code> | Text of the element |
703
+ | attributes | <code>object</code> | Element attributes |
704
+ | position | <code>name</code> \| <code>number</code> | Position name 'first', 'last' or the position in the `children` |
705
705
 
706
706
  <a name="Twig+delete"></a>
707
707
 
@@ -723,7 +723,7 @@ Sets the name of root element. In some cases the root is created before the XML-
723
723
 
724
724
  <a name="Twig+filterElements"></a>
725
725
 
726
- ### twig.filterElements(elements, [condition]) ⇒ [<code>Array.&lt;Twig&gt;</code>](#Twig)
726
+ ### twig.filterElements(elements, condition) ⇒ [<code>Array.&lt;Twig&gt;</code>](#Twig)
727
727
  Common function to filter Twig elements from array
728
728
 
729
729
  **Kind**: instance method of [<code>Twig</code>](#Twig)
@@ -732,11 +732,11 @@ Common function to filter Twig elements from array
732
732
  | Param | Type | Description |
733
733
  | --- | --- | --- |
734
734
  | elements | [<code>Twig</code>](#Twig) \| [<code>Array.&lt;Twig&gt;</code>](#Twig) | Array of elements you like to filter or a single element |
735
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | The filter condition |
735
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | The filter condition |
736
736
 
737
737
  <a name="Twig+testElement"></a>
738
738
 
739
- ### twig.testElement(element, [condition]) ⇒ <code>boolean</code>
739
+ ### twig.testElement(element, condition) ⇒ <code>boolean</code>
740
740
  Common function to filter Twig element
741
741
 
742
742
  **Kind**: instance method of [<code>Twig</code>](#Twig)
@@ -745,7 +745,7 @@ Common function to filter Twig element
745
745
  | Param | Type | Description |
746
746
  | --- | --- | --- |
747
747
  | element | [<code>Twig</code>](#Twig) | Element you like to filter |
748
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | The filter condition |
748
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | The filter condition |
749
749
 
750
750
  <a name="Twig"></a>
751
751
 
@@ -754,7 +754,7 @@ Common function to filter Twig element
754
754
 
755
755
  * [Twig](#Twig)
756
756
  * [new Twig()](#new_Twig_new)
757
- * [new Twig(parser, name, [parent], [attributes], [index])](#new_Twig_new)
757
+ * [new Twig(parser, name, parent, attributes, index)](#new_Twig_new)
758
758
  * [.attributes](#Twig+attributes) : <code>object</code> ℗
759
759
  * [.text](#Twig+text) : <code>string</code> \| <code>number</code> ℗
760
760
  * [.name](#Twig+name) : <code>string</code> ℗
@@ -810,8 +810,8 @@ Common function to filter Twig element
810
810
  * [.addElement](#Twig+addElement) ⇒ [<code>Twig</code>](#Twig)
811
811
  * [.delete](#Twig+delete)
812
812
  * [.setRoot(name)](#Twig+setRoot) ℗
813
- * [.filterElements(elements, [condition])](#Twig+filterElements) ⇒ [<code>Array.&lt;Twig&gt;</code>](#Twig)
814
- * [.testElement(element, [condition])](#Twig+testElement) ⇒ <code>boolean</code>
813
+ * [.filterElements(elements, condition)](#Twig+filterElements) ⇒ [<code>Array.&lt;Twig&gt;</code>](#Twig)
814
+ * [.testElement(element, condition)](#Twig+testElement) ⇒ <code>boolean</code>
815
815
 
816
816
  <a name="new_Twig_new"></a>
817
817
 
@@ -820,7 +820,7 @@ Generic class modeling a XML Node
820
820
 
821
821
  <a name="new_Twig_new"></a>
822
822
 
823
- ### new Twig(parser, name, [parent], [attributes], [index])
823
+ ### new Twig(parser, name, parent, attributes, index)
824
824
  Create a new Twig object
825
825
 
826
826
 
@@ -828,9 +828,9 @@ Create a new Twig object
828
828
  | --- | --- | --- |
829
829
  | parser | [<code>Parser</code>](#Parser) | The main parser object |
830
830
  | name | <code>string</code> | The name of the XML element |
831
- | [parent] | [<code>Twig</code>](#Twig) | The parent object |
832
- | [attributes] | <code>object</code> | Attribute object |
833
- | [index] | <code>string</code> \| <code>number</code> | Position name 'first', 'last' or the position in the current `children` array.<br>Defaults to 'last' |
831
+ | parent | [<code>Twig</code>](#Twig) | The parent object |
832
+ | attributes | <code>object</code> | Attribute object |
833
+ | index | <code>string</code> \| <code>number</code> | Position name 'first', 'last' or the position in the current `children` array.<br>Defaults to 'last' |
834
834
 
835
835
  <a name="Twig+attributes"></a>
836
836
 
@@ -889,7 +889,7 @@ Purges up to the elt element. This allows you to keep part of the tree in memory
889
889
 
890
890
  | Param | Type | Description |
891
891
  | --- | --- | --- |
892
- | [elt] | [<code>Twig</code>](#Twig) | Up to this element the tree will be purged. If `undefined` then the current element is purged (i.e. `purge()`) |
892
+ | elt | [<code>Twig</code>](#Twig) | Up to this element the tree will be purged. If `undefined` then the current element is purged (i.e. `purge()`) |
893
893
 
894
894
  <a name="Twig+escapeEntity"></a>
895
895
 
@@ -1047,7 +1047,7 @@ Returns attribute value or `null` if not found.<br>
1047
1047
 
1048
1048
  | Param | Type | Description |
1049
1049
  | --- | --- | --- |
1050
- | [condition] | [<code>AttributeCondition</code>](#AttributeCondition) | Optional condition to select attribute |
1050
+ | condition | [<code>AttributeCondition</code>](#AttributeCondition) | Optional condition to select attribute |
1051
1051
 
1052
1052
  <a name="Twig+attributes"></a>
1053
1053
 
@@ -1078,8 +1078,8 @@ Retrieve or update XML attribute. For update, the condition must be a string, i.
1078
1078
 
1079
1079
  | Param | Type | Description |
1080
1080
  | --- | --- | --- |
1081
- | [condition] | [<code>AttributeCondition</code>](#AttributeCondition) | Optional condition to select attributes |
1082
- | [value] | <code>string</code> \| <code>number</code> \| <code>bigint</code> \| <code>boolean</code> | New value of the attribute.<br>If `undefined` then existing attributes is returned. |
1081
+ | condition | [<code>AttributeCondition</code>](#AttributeCondition) | Optional condition to select attributes |
1082
+ | value | <code>string</code> \| <code>number</code> \| <code>bigint</code> \| <code>boolean</code> | New value of the attribute.<br>If `undefined` then existing attributes is returned. |
1083
1083
 
1084
1084
  **Example**
1085
1085
  ```js
@@ -1124,7 +1124,7 @@ All children, optionally matching `condition` of the current element or empty ar
1124
1124
 
1125
1125
  | Param | Type | Description |
1126
1126
  | --- | --- | --- |
1127
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1127
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1128
1128
 
1129
1129
  <a name="Twig+next"></a>
1130
1130
 
@@ -1137,7 +1137,7 @@ Returns the next matching element.
1137
1137
 
1138
1138
  | Param | Type | Description |
1139
1139
  | --- | --- | --- |
1140
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1140
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1141
1141
 
1142
1142
  <a name="Twig+previous"></a>
1143
1143
 
@@ -1150,7 +1150,7 @@ Returns the previous matching element.
1150
1150
 
1151
1151
  | Param | Type | Description |
1152
1152
  | --- | --- | --- |
1153
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1153
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1154
1154
 
1155
1155
  <a name="Twig+first"></a>
1156
1156
 
@@ -1162,7 +1162,7 @@ Returns the first matching element. This is usually the root element
1162
1162
 
1163
1163
  | Param | Type | Description |
1164
1164
  | --- | --- | --- |
1165
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1165
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1166
1166
 
1167
1167
  <a name="Twig+last"></a>
1168
1168
 
@@ -1174,7 +1174,7 @@ Returns the last matching element.
1174
1174
 
1175
1175
  | Param | Type | Description |
1176
1176
  | --- | --- | --- |
1177
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1177
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1178
1178
 
1179
1179
  <a name="Twig+isFirstChild"></a>
1180
1180
 
@@ -1200,7 +1200,7 @@ Returns descendants (children, grandchildren, etc.) of the current element
1200
1200
 
1201
1201
  | Param | Type | Description |
1202
1202
  | --- | --- | --- |
1203
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1203
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1204
1204
 
1205
1205
  <a name="Twig+descendantOrSelf"></a>
1206
1206
 
@@ -1212,7 +1212,7 @@ Returns descendants (children, grandchildren, etc.) of the current element and t
1212
1212
 
1213
1213
  | Param | Type | Description |
1214
1214
  | --- | --- | --- |
1215
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1215
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1216
1216
 
1217
1217
  <a name="Twig+ancestor"></a>
1218
1218
 
@@ -1224,7 +1224,7 @@ Returns ancestors (parent, grandparent, etc.) of the current element
1224
1224
 
1225
1225
  | Param | Type | Description |
1226
1226
  | --- | --- | --- |
1227
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1227
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1228
1228
 
1229
1229
  <a name="Twig+ancestorOrSelf"></a>
1230
1230
 
@@ -1236,7 +1236,7 @@ Returns ancestors (parent, grandparent, etc.) of the current element and the cu
1236
1236
 
1237
1237
  | Param | Type | Description |
1238
1238
  | --- | --- | --- |
1239
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1239
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1240
1240
 
1241
1241
  <a name="Twig+sibling"></a>
1242
1242
 
@@ -1248,7 +1248,7 @@ Returns all sibling element of the current element
1248
1248
 
1249
1249
  | Param | Type | Description |
1250
1250
  | --- | --- | --- |
1251
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1251
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1252
1252
 
1253
1253
  <a name="Twig+siblingOrSelf"></a>
1254
1254
 
@@ -1260,7 +1260,7 @@ Returns all sibling element of the current element and the current element itsel
1260
1260
 
1261
1261
  | Param | Type | Description |
1262
1262
  | --- | --- | --- |
1263
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1263
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1264
1264
 
1265
1265
  <a name="Twig+followingSibling"></a>
1266
1266
 
@@ -1272,7 +1272,7 @@ Returns all following sibling element of the current element
1272
1272
 
1273
1273
  | Param | Type | Description |
1274
1274
  | --- | --- | --- |
1275
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1275
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1276
1276
 
1277
1277
  <a name="Twig+precedingSibling"></a>
1278
1278
 
@@ -1284,7 +1284,7 @@ Returns all preceding sibling element of the current element
1284
1284
 
1285
1285
  | Param | Type | Description |
1286
1286
  | --- | --- | --- |
1287
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1287
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1288
1288
 
1289
1289
  <a name="Twig+nextSibling"></a>
1290
1290
 
@@ -1296,7 +1296,7 @@ Returns next sibling element of the current element
1296
1296
 
1297
1297
  | Param | Type | Description |
1298
1298
  | --- | --- | --- |
1299
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1299
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1300
1300
 
1301
1301
  <a name="Twig+prevSibling"></a>
1302
1302
 
@@ -1308,7 +1308,7 @@ Returns previous sibling element of the current element
1308
1308
 
1309
1309
  | Param | Type | Description |
1310
1310
  | --- | --- | --- |
1311
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1311
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | Optional condition |
1312
1312
 
1313
1313
  <a name="Twig+find"></a>
1314
1314
 
@@ -1333,9 +1333,9 @@ Add a new element in the current element
1333
1333
  | Param | Type | Description |
1334
1334
  | --- | --- | --- |
1335
1335
  | name | <code>string</code> | The tag name |
1336
- | [text] | <code>string</code> | Text of the element |
1337
- | [attributes] | <code>object</code> | Element attributes |
1338
- | [position] | <code>name</code> \| <code>number</code> | Position name 'first', 'last' or the position in the `children` |
1336
+ | text | <code>string</code> | Text of the element |
1337
+ | attributes | <code>object</code> | Element attributes |
1338
+ | position | <code>name</code> \| <code>number</code> | Position name 'first', 'last' or the position in the `children` |
1339
1339
 
1340
1340
  <a name="Twig+delete"></a>
1341
1341
 
@@ -1357,7 +1357,7 @@ Sets the name of root element. In some cases the root is created before the XML-
1357
1357
 
1358
1358
  <a name="Twig+filterElements"></a>
1359
1359
 
1360
- ### twig.filterElements(elements, [condition]) ⇒ [<code>Array.&lt;Twig&gt;</code>](#Twig)
1360
+ ### twig.filterElements(elements, condition) ⇒ [<code>Array.&lt;Twig&gt;</code>](#Twig)
1361
1361
  Common function to filter Twig elements from array
1362
1362
 
1363
1363
  **Kind**: instance method of [<code>Twig</code>](#Twig)
@@ -1366,11 +1366,11 @@ Common function to filter Twig elements from array
1366
1366
  | Param | Type | Description |
1367
1367
  | --- | --- | --- |
1368
1368
  | elements | [<code>Twig</code>](#Twig) \| [<code>Array.&lt;Twig&gt;</code>](#Twig) | Array of elements you like to filter or a single element |
1369
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | The filter condition |
1369
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | The filter condition |
1370
1370
 
1371
1371
  <a name="Twig+testElement"></a>
1372
1372
 
1373
- ### twig.testElement(element, [condition]) ⇒ <code>boolean</code>
1373
+ ### twig.testElement(element, condition) ⇒ <code>boolean</code>
1374
1374
  Common function to filter Twig element
1375
1375
 
1376
1376
  **Kind**: instance method of [<code>Twig</code>](#Twig)
@@ -1379,7 +1379,7 @@ Common function to filter Twig element
1379
1379
  | Param | Type | Description |
1380
1380
  | --- | --- | --- |
1381
1381
  | element | [<code>Twig</code>](#Twig) | Element you like to filter |
1382
- | [condition] | [<code>ElementCondition</code>](#ElementCondition) | The filter condition |
1382
+ | condition | [<code>ElementCondition</code>](#ElementCondition) | The filter condition |
1383
1383
 
1384
1384
  <a name="NotImplementedYet"></a>
1385
1385
 
@@ -1446,7 +1446,7 @@ Generic error for unsupported condition
1446
1446
 
1447
1447
  ## SAX
1448
1448
  **Kind**: global constant
1449
- **Version:**: 1.7.11
1449
+ **Version:**: 1.7.12
1450
1450
  **Author:**: Wernfried Domscheit
1451
1451
  **Copyright:**: Copyright (c) 2025 Wernfried Domscheit. All rights reserved.
1452
1452
  **Website:**: https://www.npmjs.com/package/xml-twig
@@ -1460,7 +1460,7 @@ Generic error for unsupported condition
1460
1460
  **Kind**: global constant
1461
1461
  <a name="createParser"></a>
1462
1462
 
1463
- ## createParser(handler, [options]) ⇒ [<code>Parser</code>](#Parser)
1463
+ ## createParser(handler, options) ⇒ [<code>Parser</code>](#Parser)
1464
1464
  Create a new Twig parser
1465
1465
 
1466
1466
  **Kind**: global function
@@ -1473,7 +1473,7 @@ Create a new Twig parser
1473
1473
  | Param | Type | Description |
1474
1474
  | --- | --- | --- |
1475
1475
  | handler | [<code>TwigHandler</code>](#TwigHandler) \| [<code>Array.&lt;TwigHandler&gt;</code>](#TwigHandler) | Object or array of element specification and function to handle elements |
1476
- | [options] | [<code>ParserOptions</code>](#ParserOptions) | Object of optional options |
1476
+ | options | [<code>ParserOptions</code>](#ParserOptions) | Object of optional options |
1477
1477
 
1478
1478
  <a name="onStart"></a>
1479
1479
 
@@ -1515,12 +1515,12 @@ Optional settings for the Twig parser
1515
1515
 
1516
1516
  | Name | Type | Description |
1517
1517
  | --- | --- | --- |
1518
- | [method] | <code>&#x27;sax&#x27;</code> \| <code>&#x27;expat&#x27;</code> | The underlying parser. Either `'sax'`, `'expat'`. |
1519
- | [xmlns] | <code>boolean</code> | If `true`, then namespaces are accessible by `namespace` property. |
1520
- | [trim] | <code>boolean</code> | If `true`, then turn any whitespace into a single space. Text and comments are trimmed. |
1521
- | [resumeAfterError] | <code>boolean</code> | If `true` then parser continues reading after an error. Otherwise it throws exception. |
1522
- | [partial] | <code>boolean</code> | If `true` then unhandled elements are purged. |
1523
- | [file] | <code>string</code> | Optional. The name of file to be parsed. Just used for information and logging purpose. |
1518
+ | method | <code>&#x27;sax&#x27;</code> \| <code>&#x27;expat&#x27;</code> | The underlying parser. Either `'sax'`, `'expat'`. |
1519
+ | xmlns | <code>boolean</code> | If `true`, then namespaces are accessible by `namespace` property. |
1520
+ | trim | <code>boolean</code> | If `true`, then turn any whitespace into a single space. Text and comments are trimmed. |
1521
+ | resumeAfterError | <code>boolean</code> | If `true` then parser continues reading after an error. Otherwise it throws exception. |
1522
+ | partial | <code>boolean</code> | If `true` then unhandled elements are purged. |
1523
+ | file | <code>string</code> | Optional. The name of file to be parsed. Just used for information and logging purpose. |
1524
1524
 
1525
1525
  **Example**
1526
1526
  ```js
@@ -1537,8 +1537,8 @@ Reference to handler functions for Twig objects.<br>
1537
1537
  | Name | Type | Description |
1538
1538
  | --- | --- | --- |
1539
1539
  | tag | [<code>HandlerCondition</code>](#HandlerCondition) | Element specification |
1540
- | [function] | [<code>HandlerFunction</code>](#HandlerFunction) | Definition of handler function, either anonymous or explicit function |
1541
- | [event] | <code>string</code> | Type of the event to be emitted |
1540
+ | function | [<code>HandlerFunction</code>](#HandlerFunction) | Definition of handler function, either anonymous or explicit function |
1541
+ | event | <code>string</code> | Type of the event to be emitted |
1542
1542
 
1543
1543
  <a name="HandlerCondition"></a>
1544
1544
 
@@ -1597,11 +1597,11 @@ Custom filter function to select desired elements
1597
1597
 
1598
1598
  | Name | Type | Description |
1599
1599
  | --- | --- | --- |
1600
- | [currentLine] | <code>number</code> | The currently processed line in the XML-File. |
1601
- | [currentColumn] | <code>number</code> | The currently processed column in the XML-File. |
1602
- | [file] | <code>string</code> | The name of file to be parsed. Just used for information and logging purpose. |
1603
- | [twig] | <code>object</code> | Object with XML tree and current XML element |
1604
- | [method] | <code>string</code> | The underlying parser. Either `'sax'`, `'expat'`. |
1600
+ | currentLine | <code>number</code> | The currently processed line in the XML-File. |
1601
+ | currentColumn | <code>number</code> | The currently processed column in the XML-File. |
1602
+ | file | <code>string</code> | The name of file to be parsed. Just used for information and logging purpose. |
1603
+ | twig | <code>object</code> | Object with XML tree and current XML element |
1604
+ | method | <code>string</code> | The underlying parser. Either `'sax'`, `'expat'`. |
1605
1605
 
1606
1606
  <a name="AttributeCondition"></a>
1607
1607
 
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  },
6
6
  "name": "xml-twig",
7
7
  "description": "Node module for processing huge XML documents in tree mode",
8
- "version": "1.7.12",
8
+ "version": "1.7.13",
9
9
  "main": "twig.js",
10
10
  "directories": {
11
11
  "doc": "doc"
package/twig.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @version: 1.7.12
2
+ * @version: 1.7.13
3
3
  * @author: Wernfried Domscheit
4
4
  * @copyright: Copyright (c) 2025 Wernfried Domscheit. All rights reserved.
5
5
  * @website: https://www.npmjs.com/package/xml-twig
@@ -62,12 +62,12 @@ const Any = new AnyHandler();
62
62
  /**
63
63
  * Optional settings for the Twig parser
64
64
  * @typedef ParserOptions
65
- * @property {'sax' | 'expat'} [method] - The underlying parser. Either `'sax'`, `'expat'`.
66
- * @property {boolean} [xmlns] - If `true`, then namespaces are accessible by `namespace` property.
67
- * @property {boolean} [trim] - If `true`, then turn any whitespace into a single space. Text and comments are trimmed.
68
- * @property {boolean} [resumeAfterError] - If `true` then parser continues reading after an error. Otherwise it throws exception.
69
- * @property {boolean} [partial] - If `true` then unhandled elements are purged.
70
- * @property {string} [file] - Optional. The name of file to be parsed. Just used for information and logging purpose.
65
+ * @property {'sax' | 'expat'} method - The underlying parser. Either `'sax'`, `'expat'`.
66
+ * @property {boolean} xmlns - If `true`, then namespaces are accessible by `namespace` property.
67
+ * @property {boolean} trim - If `true`, then turn any whitespace into a single space. Text and comments are trimmed.
68
+ * @property {boolean} resumeAfterError - If `true` then parser continues reading after an error. Otherwise it throws exception.
69
+ * @property {boolean} partial - If `true` then unhandled elements are purged.
70
+ * @property {string} [file - Optional. The name of file to be parsed. Just used for information and logging purpose.
71
71
  * @example { method: 'expat', xmlns: true }
72
72
  * @default { method: 'sax', xmlns: false, trim: true, resumeAfterError: false, partial: false }
73
73
  */
@@ -78,8 +78,8 @@ const Any = new AnyHandler();
78
78
  * You can specify a `function` or a `event` name
79
79
  * @typedef TwigHandler
80
80
  * @property {HandlerCondition} tag - Element specification
81
- * @property {HandlerFunction} [function] - Definition of handler function, either anonymous or explicit function
82
- * @property {string} [event] - Type of the event to be emitted
81
+ * @property {HandlerFunction} function - Definition of handler function, either anonymous or explicit function
82
+ * @property {string} event - Type of the event to be emitted
83
83
  */
84
84
 
85
85
  /**
@@ -126,18 +126,18 @@ const Any = new AnyHandler();
126
126
 
127
127
  /**
128
128
  * @typedef Parser
129
- * @property {number} [currentLine] - The currently processed line in the XML-File.
130
- * @property {number} [currentColumn] - The currently processed column in the XML-File.
131
- * @property {string} [file] - The name of file to be parsed. Just used for information and logging purpose.
132
- * @property {object} [twig] - Object with XML tree and current XML element
133
- * @property {string} [method] - The underlying parser. Either `'sax'`, `'expat'`.
129
+ * @property {number} currentLine - The currently processed line in the XML-File.
130
+ * @property {number} currentColumn - The currently processed column in the XML-File.
131
+ * @property {string} file - The name of file to be parsed. Just used for information and logging purpose.
132
+ * @property {object} twig - Object with XML tree and current XML element
133
+ * @property {string} method - The underlying parser. Either `'sax'`, `'expat'`.
134
134
  * @returns {external:sax|external:node-expat} The parser Object
135
135
  */
136
136
 
137
137
  /**
138
138
  * Create a new Twig parser
139
139
  * @param {TwigHandler|TwigHandler[]} handler - Object or array of element specification and function to handle elements
140
- * @param {ParserOptions} [options] - Object of optional options
140
+ * @param {ParserOptions} options - Object of optional options
141
141
  * @throws {UnsupportedParser} - For an unsupported parser. Currently `expat` and `sax` (default) are supported.
142
142
  * @returns {Parser} The parser Object
143
143
  */
@@ -517,9 +517,9 @@ class Twig {
517
517
  * Create a new Twig object
518
518
  * @param {Parser} parser - The main parser object
519
519
  * @param {?string} name - The name of the XML element
520
- * @param {Twig} [parent] - The parent object
521
- * @param {object} [attributes] - Attribute object
522
- * @param {string|number} [index] - Position name 'first', 'last' or the position in the current `children` array.<br>Defaults to 'last'
520
+ * @param {Twig} parent - The parent object
521
+ * @param {object} attributes - Attribute object
522
+ * @param {string|number} index - Position name 'first', 'last' or the position in the current `children` array.<br>Defaults to 'last'
523
523
  */
524
524
  constructor(parser, name, parent, attributes, index) {
525
525
  if (index === undefined)
@@ -564,7 +564,7 @@ class Twig {
564
564
  /**
565
565
  * Purges up to the elt element. This allows you to keep part of the tree in memory when you purge.<br>
566
566
  * The `elt` object is not purged. If you like to purge including `elt`, use `.purgeUpTo(elt.previous())`
567
- * @param {Twig} [elt] - Up to this element the tree will be purged.
567
+ * @param {Twig} elt - Up to this element the tree will be purged.
568
568
  * If `undefined` then the current element is purged (i.e. `purge()`)
569
569
  */
570
570
  purgeUpTo = function (elt) {
@@ -797,7 +797,7 @@ class Twig {
797
797
  /**
798
798
  * Returns attribute value or `null` if not found.<br>
799
799
  * If more than one matches the condition, then it returns object as [attribute()](#attribute)
800
- * @param {AttributeCondition} [condition] - Optional condition to select attribute
800
+ * @param {AttributeCondition} condition - Optional condition to select attribute
801
801
  * @returns {?string|number|object} - The value of the attribute or `null` if the does not exist
802
802
  */
803
803
  attr = function (condition) {
@@ -827,8 +827,8 @@ class Twig {
827
827
 
828
828
  /**
829
829
  * Retrieve or update XML attribute. For update, the condition must be a string, i.e. must match to one attribute only.
830
- * @param {AttributeCondition} [condition] - Optional condition to select attributes
831
- * @param {string|number|bigint|boolean} [value] - New value of the attribute.<br>If `undefined` then existing attributes is returned.
830
+ * @param {AttributeCondition} condition - Optional condition to select attributes
831
+ * @param {string|number|bigint|boolean} value - New value of the attribute.<br>If `undefined` then existing attributes is returned.
832
832
  * @returns {object} Attributes or `null` if no matching attribute found
833
833
  * @example attribute((name, val) => { return name === 'age' && val > 50})
834
834
  * attribute((name) => { return ['firstName', 'lastName'].includes(name) })
@@ -906,7 +906,7 @@ class Twig {
906
906
  /**
907
907
  * Common function to filter Twig elements from array
908
908
  * @param {Twig|Twig[]} elements - Array of elements you like to filter or a single element
909
- * @param {ElementCondition} [condition] - The filter condition
909
+ * @param {ElementCondition} condition - The filter condition
910
910
  * @returns {Twig[]} List of matching elements or empty array
911
911
  */
912
912
  filterElements(elements, condition) {
@@ -931,7 +931,7 @@ class Twig {
931
931
  /**
932
932
  * Common function to filter Twig element
933
933
  * @param {Twig} element - Element you like to filter
934
- * @param {ElementCondition} [condition] - The filter condition
934
+ * @param {ElementCondition} condition - The filter condition
935
935
  * @returns {boolean} `true` if the condition matches
936
936
  */
937
937
  testElement(element, condition) {
@@ -951,7 +951,7 @@ class Twig {
951
951
 
952
952
  /**
953
953
  * All children, optionally matching `condition` of the current element or empty array
954
- * @param {ElementCondition} [condition] - Optional condition
954
+ * @param {ElementCondition} condition - Optional condition
955
955
  * @returns {Twig[]}
956
956
  */
957
957
  children = function (condition) {
@@ -960,7 +960,7 @@ class Twig {
960
960
 
961
961
  /**
962
962
  * Returns the next matching element.
963
- * @param {ElementCondition} [condition] - Optional condition
963
+ * @param {ElementCondition} condition - Optional condition
964
964
  * @returns {?Twig} - The next element
965
965
  * @see https://www.w3.org/TR/xpath-datamodel-31/#document-order
966
966
  */
@@ -986,7 +986,7 @@ class Twig {
986
986
 
987
987
  /**
988
988
  * Returns the previous matching element.
989
- * @param {ElementCondition} [condition] - Optional condition
989
+ * @param {ElementCondition} condition - Optional condition
990
990
  * @returns {?Twig} - The previous element
991
991
  * @see https://www.w3.org/TR/xpath-datamodel-31/#document-order
992
992
  */
@@ -1007,7 +1007,7 @@ class Twig {
1007
1007
 
1008
1008
  /**
1009
1009
  * Returns the first matching element. This is usually the root element
1010
- * @param {ElementCondition} [condition] - Optional condition
1010
+ * @param {ElementCondition} condition - Optional condition
1011
1011
  * @returns {?Twig} - The first element
1012
1012
  */
1013
1013
  first = function (condition) {
@@ -1018,7 +1018,7 @@ class Twig {
1018
1018
 
1019
1019
  /**
1020
1020
  * Returns the last matching element.
1021
- * @param {ElementCondition} [condition] - Optional condition
1021
+ * @param {ElementCondition} condition - Optional condition
1022
1022
  * @returns {?Twig} - The last element
1023
1023
  */
1024
1024
  last = function (condition) {
@@ -1061,7 +1061,7 @@ class Twig {
1061
1061
 
1062
1062
  /**
1063
1063
  * Returns descendants (children, grandchildren, etc.) of the current element
1064
- * @param {ElementCondition} [condition] - Optional condition
1064
+ * @param {ElementCondition} condition - Optional condition
1065
1065
  * @returns {Twig[]} - Array of descendants or empty array
1066
1066
  */
1067
1067
  descendant = function (condition) {
@@ -1075,7 +1075,7 @@ class Twig {
1075
1075
 
1076
1076
  /**
1077
1077
  * Returns descendants (children, grandchildren, etc.) of the current element and the current element itself
1078
- * @param {ElementCondition} [condition] - Optional condition
1078
+ * @param {ElementCondition} condition - Optional condition
1079
1079
  * @returns {Twig[]} - Array of descendants or empty array
1080
1080
  */
1081
1081
  descendantOrSelf = function (condition) {
@@ -1089,7 +1089,7 @@ class Twig {
1089
1089
 
1090
1090
  /**
1091
1091
  * Returns ancestors (parent, grandparent, etc.) of the current element
1092
- * @param {ElementCondition} [condition] - Optional condition
1092
+ * @param {ElementCondition} condition - Optional condition
1093
1093
  * @returns {Twig[]} - Array of ancestors or empty array
1094
1094
  */
1095
1095
  ancestor = function (condition) {
@@ -1107,7 +1107,7 @@ class Twig {
1107
1107
 
1108
1108
  /**
1109
1109
  * Returns ancestors (parent, grandparent, etc.) of the current element and the current element itself
1110
- * @param {ElementCondition} [condition] - Optional condition
1110
+ * @param {ElementCondition} condition - Optional condition
1111
1111
  * @returns {Twig[]} - Array of ancestors or empty array
1112
1112
  */
1113
1113
  ancestorOrSelf = function (condition) {
@@ -1125,7 +1125,7 @@ class Twig {
1125
1125
 
1126
1126
  /**
1127
1127
  * Returns all sibling element of the current element
1128
- * @param {ElementCondition} [condition] - Optional condition
1128
+ * @param {ElementCondition} condition - Optional condition
1129
1129
  * @returns {Twig[]} - Array of sibling or empty array
1130
1130
  */
1131
1131
  sibling = function (condition) {
@@ -1138,7 +1138,7 @@ class Twig {
1138
1138
 
1139
1139
  /**
1140
1140
  * Returns all sibling element of the current element and the current element itself
1141
- * @param {ElementCondition} [condition] - Optional condition
1141
+ * @param {ElementCondition} condition - Optional condition
1142
1142
  * @returns {Twig[]} - Array of sibling or empty array
1143
1143
  */
1144
1144
  siblingOrSelf = function (condition) {
@@ -1151,7 +1151,7 @@ class Twig {
1151
1151
 
1152
1152
  /**
1153
1153
  * Returns all following sibling element of the current element
1154
- * @param {ElementCondition} [condition] - Optional condition
1154
+ * @param {ElementCondition} condition - Optional condition
1155
1155
  * @returns {Twig[]} - Array of sibling or empty array
1156
1156
  */
1157
1157
  followingSibling = function (condition) {
@@ -1164,7 +1164,7 @@ class Twig {
1164
1164
 
1165
1165
  /**
1166
1166
  * Returns all preceding sibling element of the current element
1167
- * @param {ElementCondition} [condition] - Optional condition
1167
+ * @param {ElementCondition} condition - Optional condition
1168
1168
  * @returns {Twig[]} - Array of sibling or empty array
1169
1169
  */
1170
1170
  precedingSibling = function (condition) {
@@ -1177,7 +1177,7 @@ class Twig {
1177
1177
 
1178
1178
  /**
1179
1179
  * Returns next sibling element of the current element
1180
- * @param {ElementCondition} [condition] - Optional condition
1180
+ * @param {ElementCondition} condition - Optional condition
1181
1181
  * @returns {?Twig} - The next sibling or `null`
1182
1182
  */
1183
1183
  nextSibling = function (condition) {
@@ -1192,7 +1192,7 @@ class Twig {
1192
1192
 
1193
1193
  /**
1194
1194
  * Returns previous sibling element of the current element
1195
- * @param {ElementCondition} [condition] - Optional condition
1195
+ * @param {ElementCondition} condition - Optional condition
1196
1196
  * @returns {?Twig} - The previous sibling or `null`
1197
1197
  */
1198
1198
  prevSibling = function (condition) {
@@ -1225,9 +1225,9 @@ class Twig {
1225
1225
  /**
1226
1226
  * Add a new element in the current element
1227
1227
  * @param {string} name - The tag name
1228
- * @param {?string} [text] - Text of the element
1229
- * @param {?object} [attributes] - Element attributes
1230
- * @param {name|number} [position] - Position name 'first', 'last' or the position in the `children`
1228
+ * @param {?string} text - Text of the element
1229
+ * @param {?object} attributes - Element attributes
1230
+ * @param {name|number} position - Position name 'first', 'last' or the position in the `children`
1231
1231
  * @returns {Twig} - The appended element
1232
1232
  */
1233
1233
  addElement = function (parser, name, text, attributes, position) {