File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed
test/htmlx2jsx/samples/attribute-element Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -354,10 +354,12 @@ export function convertHtmlxToJsx(
354354 } ;
355355
356356 const handleAttribute = ( attr : Node , parent : Node ) => {
357+ let transformedFromDirectiveOrNamespace = false ;
358+
357359 //if we are on an "element" we are case insensitive, lowercase to match our JSX
358360 if ( parent . type == 'Element' ) {
359- //skip Attribute shorthand, that is handled below
360361 const sapperNoScroll = attr . name === 'sapper:noscroll' ;
362+ //skip Attribute shorthand, that is handled below
361363 if (
362364 ( attr . value !== true &&
363365 ! (
@@ -380,11 +382,22 @@ export function convertHtmlxToJsx(
380382 }
381383
382384 str . overwrite ( attr . start , attr . start + attr . name . length , name ) ;
385+
386+ transformedFromDirectiveOrNamespace = true ;
383387 }
384388 }
385389
386390 //we are a bare attribute
387- if ( attr . value === true ) return ;
391+ if ( attr . value === true ) {
392+ if (
393+ parent . type === 'Element' &&
394+ ! transformedFromDirectiveOrNamespace &&
395+ parent . name !== '!DOCTYPE'
396+ ) {
397+ str . overwrite ( attr . start , attr . end , attr . name . toLowerCase ( ) ) ;
398+ }
399+ return ;
400+ }
388401
389402 if ( attr . value . length == 0 ) return ; //wut?
390403 //handle single value
Original file line number Diff line number Diff line change 1+ < > < div contenteditable > </ div >
2+ < div contenteditable = { contentEditable } > </ div >
3+ < div contenteditable = { contenteditable } > </ div > </ >
Original file line number Diff line number Diff line change 1+ <div contentEditable ></div >
2+ <div {contentEditable }></div >
3+ <div contentEditable ={contenteditable }></div >
You can’t perform that action at this time.
0 commit comments