File tree 4 files changed +22
-6
lines changed
4 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ wasm-pack build --target nodejs
16
16
17
17
echo " ---> Patching JavaScript glue code..."
18
18
# Wraps write/end with asyncify magic and adds this returns for chaining
19
+ # diff -uN pkg/html_rewriter.js pkg2/html_rewriter.js > html_rewriter.js.patch
19
20
patch -uN pkg/html_rewriter.js < html_rewriter.js.patch
20
21
21
22
echo " ---> Copying required files to dist..."
Original file line number Diff line number Diff line change 1
- --- pkg/html_rewriter.js 2021-07-21 19:45:46 .000000000 +0100
2
- +++ pkg2/html_rewriter.js 2021-07-21 19:44:41 .000000000 +0100
1
+ --- pkg/html_rewriter.js 2021-07-22 16:09:24 .000000000 +0100
2
+ +++ pkg2/html_rewriter.js 2021-07-22 16:10:13 .000000000 +0100
3
3
@@ -1,7 +1,7 @@
4
4
let imports = {};
5
5
imports['__wbindgen_placeholder__'] = module.exports;
77
77
}
78
78
/**
79
79
* @returns {boolean}
80
+ @@ -463,7 +472,7 @@
81
+ */
82
+ get attributes() {
83
+ var ret = wasm.element_attributes(this.ptr);
84
+ - return takeObject(ret);
85
+ + return takeObject(ret)[Symbol.iterator]();
86
+ }
87
+ /**
88
+ * @param {string} name
80
89
@@ -495,6 +504,7 @@
81
90
var ptr1 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
82
91
var len1 = WASM_VECTOR_LEN;
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ export class Element {
15
15
append ( content : string , options ?: ContentTypeOptions ) : this;
16
16
setInnerContent ( content : string , options ?: ContentTypeOptions ) : this;
17
17
removeAndKeepContent ( ) : this;
18
- readonly attributes : [ string , string ] [ ] ;
18
+ readonly attributes : IterableIterator < [ string , string ] > ;
19
19
readonly namespaceURI : string ;
20
20
readonly removed : boolean ;
21
21
tagName : string ;
@@ -47,7 +47,7 @@ export class Doctype {
47
47
}
48
48
49
49
export class DocumentEnd {
50
- append ( content : string , options ?: ContentTypeOptions ) : DocumentEnd ;
50
+ append ( content : string , options ?: ContentTypeOptions ) : this ;
51
51
}
52
52
53
53
export interface ElementHandlers {
Original file line number Diff line number Diff line change @@ -19,15 +19,21 @@ const elementMutationsExpected = {
19
19
} ;
20
20
21
21
test ( "handles element properties" , async ( t ) => {
22
- t . plan ( 5 ) ;
22
+ t . plan ( 6 ) ;
23
23
const res = await new HTMLRewriter ( )
24
24
. on ( "p" , {
25
25
element ( element ) {
26
26
t . is ( element . tagName , "p" ) ;
27
27
element . tagName = "h1" ;
28
- t . deepEqual ( [ ...element . attributes ] , [ [ "class" , "red" ] ] ) ;
29
28
t . false ( element . removed ) ;
30
29
t . is ( element . namespaceURI , "http://www.w3.org/1999/xhtml" ) ;
30
+
31
+ // Check element.attributes is an IterableIterator
32
+ t . deepEqual ( element . attributes . next ( ) , {
33
+ value : [ "class" , "red" ] ,
34
+ done : false ,
35
+ } ) ;
36
+ t . deepEqual ( [ ...element . attributes ] , [ [ "class" , "red" ] ] ) ;
31
37
} ,
32
38
} )
33
39
. transform ( '<p class="red">test</p>' ) ;
You can’t perform that action at this time.
0 commit comments