You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<sub>*built for node but *should* run in the browser</sub>
30
30
31
31
## Installation
@@ -88,17 +88,22 @@ if (ready) {
88
88
}
89
89
}
90
90
```
91
+
## The 'Lifetime' of events
92
+
`Tag`, `Attribute`, `ProcInst` and `Text` objects received from the parsing operation have a 'lifetime' that is limited to the `eventHandler()` or the function loop body for the `*parse()` generator. Data sent across the FFI (Foreign Function Interface) boundary is read directly from WASM memory which is partly why sax-wasm is so fast. This comes with the tradeoff that this memory is temporary because it is overwritten on the next write operation. If you need to persist the event data for long term use, call `toJSON()` on each object as needed. This comes at a slight performance cost and should not be necessary for the vast majority of use cases.
91
93
92
-
## Differences from sax-js
93
-
Besides being incredibly fast, there are some notable differences between sax-wasm and sax-js that may affect some users
94
-
when migrating:
94
+
## Differences from other parsers
95
+
Besides being incredibly fast, there are some notable differences between other SAX style parsers:
95
96
97
+
1. This repo is maintained
98
+
1. UTF-16 encoded documents are supported. 1-4 byte graphemes are fully supported even if streaming causes a break between surrogates.
96
99
1. JSX is supported including JSX fragments. Things like `<foo bar={this.bar()}></bar>` and `<><foo/><bar/></>` will parse as expected.
97
100
1. Angular 2+ templates are supported. Things like <button type="submit" [disabled]=disabled *ngIf=boolean (click)="clickHandler(event)"></button> will parse as expected.
101
+
1. HTML is supported provided it is not a "quirks mode" document that ran in IE9.
98
102
1. No attempt is made to validate the document. sax-wasm reports what it sees. If you need strict mode or document validation, it may
99
103
be recreated by applying rules to the events that are reported by the parser.
100
104
1. Namespaces are reported in attributes. No special events dedicated to namespaces.
101
105
1. Streaming utf-8 code points in a Uint8Array is required.
106
+
1. Whitespace between XML elements is not reported. If you need this, a simple subtraction of the `line` and `character` between the end of one tag and the start of the next will reveal where this whitespace exists.
102
107
103
108
## Streaming
104
109
Streaming is supported with sax-wasm by writing utf-8 code points (Uint8Array) to the parser instance. Writes can occur safely
0 commit comments