@@ -27,31 +27,11 @@ pub(crate) enum RewriteType<'alloc: 'data, 'data> {
2727 /// `cfg.metafn("cfg.base")`
2828 MetaFn ,
2929
30- /// `window.attr` -> cfg.wrapattr(window)
31- WrapGet {
32- ident : Atom < ' data > ,
33- propspan : Span ,
34- enclose : bool ,
35- } ,
36- /// `window["attr"]` -> cfg.wrapgetcomputed(window, "attr")
37- WrapGetComputed {
38- leftspan : Span ,
39- propspan : Span ,
40- enclose : bool ,
41- } ,
42- /// `window.attr` -> cfg.wrapattr(window)
43- WrapSet {
44- ident : Atom < ' data > ,
45- propspan : Span ,
46- leftspan : Span ,
47- rightspan : Span ,
48- } ,
49- /// `cfg.wrapcomputedsetfn(window, "attr", t)`
50- WrapSetComputed {
51- propspan : Span ,
52- leftspan : Span ,
53- rightspan : Span ,
30+ RewriteProperty {
31+ ident : Atom < ' data > ,
5432 } ,
33+ WrapProperty ,
34+
5535 // dead code only if debug is disabled
5636 #[ allow( dead_code) ]
5737 /// `$scramerr(name)`
@@ -102,6 +82,8 @@ impl<'alloc: 'data, 'data> Rewrite<'alloc, 'data> {
10282
10383impl < ' alloc : ' data , ' data > RewriteType < ' alloc , ' data > {
10484 fn into_inner ( self , span : Span ) -> SmallVec < [ JsChange < ' alloc , ' data > ; 2 ] > {
85+
86+ dbg ! ( & self ) ;
10587 macro_rules! span {
10688 ( start) => {
10789 Span :: new( span. start, span. start)
@@ -125,66 +107,13 @@ impl<'alloc: 'data, 'data> RewriteType<'alloc, 'data> {
125107 change!( span!( start) , WrapFnLeft { enclose } ) ,
126108 change!( span!( end) , WrapFnRight { enclose } ) ,
127109 ] ,
128- Self :: WrapGet {
129- ident,
130- propspan,
131- enclose,
132- } => smallvec ! [
133- change!( span!( start) , WrapGetLeft { ident, enclose } ) ,
134- change!( propspan. expand_left( 1 ) , WrapGetRight { enclose } ) ,
135- ] ,
136- Self :: WrapGetComputed {
137- leftspan,
138- propspan,
139- enclose,
140- } => smallvec ! [
141- change!( span!( start) , WrapGetComputedLeft { enclose } ) ,
142- // replace the bracket with ,
143- change!( span!( leftspan propspan between) , Replace { text: "," } ) ,
144- // replace the other bracket with )
145- change!(
146- Span :: new( propspan. end, propspan. end + 1 ) ,
147- ClosingParen {
148- semi: false ,
149- replace: true
150- }
151- ) ,
152- ] ,
153- Self :: WrapSet {
154- ident,
155- propspan,
156- leftspan,
157- rightspan,
158- } => smallvec ! [
159- change!( span!( start) , WrapSet { ident, propspan } ) ,
160- change!( propspan, Delete ) ,
161- change!( span!( leftspan rightspan between) , Replace { text: "," } ) ,
162- change!(
163- span!( end) ,
164- ClosingParen {
165- semi: false ,
166- replace: true
167- }
168- )
169- ] ,
170- RewriteType :: WrapSetComputed {
171- leftspan,
172- rightspan,
173- propspan,
174- } => smallvec ! [
175- change!( span!( start) , WrapSetComputed ) ,
176- // replace the bracket with ,
177- change!( span!( leftspan propspan between) , Replace { text: "," } ) ,
178- // replace the other bracket with another ,
179- change!( span!( propspan rightspan between) , Replace { text: "," } ) ,
180- change!(
181- span!( end) ,
182- ClosingParen {
183- semi: false ,
184- replace: true
185- }
186- )
187- ] ,
110+ Self :: RewriteProperty { ident } => smallvec ! [
111+ change!( span, RewriteProperty { ident } ) ,
112+ ] ,
113+ Self :: WrapProperty => smallvec ! [
114+ change!( span!( start) , WrapPropertyLeft ) ,
115+ change!( span!( end) , ClosingParen { semi: false , replace: false } ) ,
116+ ] ,
188117 Self :: SetRealmFn => smallvec ! [ change!( span, SetRealmFn ) ] ,
189118 Self :: ImportFn => smallvec ! [ change!( span, ImportFn ) ] ,
190119 Self :: MetaFn => smallvec ! [ change!( span, MetaFn ) ] ,
0 commit comments