@@ -197,18 +197,35 @@ function convert(infile, outfile) {
197197 }
198198 }
199199
200- // Handle w-nodev and similar attributes. Wattsi handling is here:
200+ // Convert w-nodev and similar attributes to include-if/exclude-if using the
201+ // appropriate status for each. Wattsi handling is here:
201202 // https://github.com/whatwg/wattsi/blob/b9c28036a2a174f7f87315164f001120596a95f1/src/wattsi.pas#L735-L759
202- const includeAttributes = [ 'w-nodev' , 'w-nosnap' , 'w-noreview' , 'w-nosplit' ] ;
203- const excludeAttributes = [ 'w-dev' , 'w-nohtml' ] ;
204-
205- const includeSelector = includeAttributes . map ( attr => `[${ attr } ]` ) . join ( ', ' ) ;
206- for ( const elem of document . querySelectorAll ( includeSelector ) ) {
207- replaceWithChildren ( elem ) ;
208- }
209- const excludeSelector = excludeAttributes . map ( attr => `[${ attr } ]` ) . join ( ', ' ) ;
210- for ( const elem of document . querySelectorAll ( excludeSelector ) ) {
211- elem . remove ( ) ;
203+ // TODO: w-nosplit, which doesn't correspond to a status.
204+ const conditions = [
205+ [ 'html' , 'LS' ] ,
206+ [ 'dev' , 'LS-DEV' ] ,
207+ [ 'snap' , 'LS-COMMIT' ] ,
208+ [ 'review' , 'whatwg/RD' ] ,
209+ ] ;
210+ for ( const elem of document . querySelectorAll ( "*" ) ) {
211+ const includeIf = [ ] ;
212+ const excludeIf = [ ] ;
213+ for ( const [ cond , status ] of conditions ) {
214+ if ( elem . hasAttribute ( `w-${ cond } ` ) ) {
215+ includeIf . push ( status ) ;
216+ elem . removeAttribute ( `w-${ cond } ` ) ;
217+ }
218+ if ( elem . hasAttribute ( `w-no${ cond } ` ) ) {
219+ excludeIf . push ( status ) ;
220+ elem . removeAttribute ( `w-no${ cond } ` ) ;
221+ }
222+ }
223+ if ( includeIf . length ) {
224+ elem . setAttribute ( 'include-if' , includeIf . join ( ', ' ) ) ;
225+ }
226+ if ( excludeIf . length ) {
227+ elem . setAttribute ( 'exclude-if' , excludeIf . join ( ', ' ) ) ;
228+ }
212229 }
213230
214231 // Scan all definitions
@@ -345,6 +362,8 @@ function convert(infile, outfile) {
345362 const value = span . getAttribute ( name ) ;
346363 switch ( name ) {
347364 case 'data-x' :
365+ case 'exclude-if' :
366+ case 'include-if' :
348367 break ;
349368 case 'data-lt' :
350369 case 'id' :
0 commit comments