Skip to content

Commit b1a3008

Browse files
committed
fix: issue with expression continuations containing equals
1 parent 41b9e2b commit b1a3008

File tree

4 files changed

+316
-340
lines changed

4 files changed

+316
-340
lines changed

.changeset/strong-buckets-attack.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"htmljs-parser": patch
3+
---
4+
5+
Fix expression continuations containing equals not consuming enough characters

src/__tests__/fixtures/attr-operators-space-before/__snapshots__/attr-operators-space-before.expected.txt

+118-131
Original file line numberDiff line numberDiff line change
@@ -493,10 +493,10 @@
493493
│ │╰─ attrName
494494
╰─ ╰─ tagName
495495
66╭─ <a=x >=y a/>
496-
│ │││ │╰─ text "=y a/>\n"
497-
│ │││ ╰─ openTagEnd
498-
│ ││╰─ attrValue.value
499-
│ │├─ attrValue "=x"
496+
│ │││ │╰─ openTagEnd:selfClosed "/>"
497+
│ │││ ╰─ attrName
498+
│ ││╰─ attrValue.value "x >=y"
499+
│ │├─ attrValue "=x >=y"
500500
│ │╰─ attrName
501501
╰─ ╰─ tagName
502502
67╭─ <a=x &=y a/>
@@ -507,125 +507,110 @@
507507
│ │╰─ attrName
508508
╰─ ╰─ tagName
509509
68╭─ <a=x &&=y a/>
510-
│ ││││ │╰─ openTagEnd:selfClosed "/>"
511-
│ ││││ ╰─ attrName
512-
│ │││╰─ attrValue.value "x &&=y"
513-
│ ││├─ attrValue "=x &&=y"
514-
│ ││╰─ attrName
515-
│ │╰─ tagName
516-
╰─ ╰─ text "\n"
510+
│ │││ │╰─ openTagEnd:selfClosed "/>"
511+
│ │││ ╰─ attrName
512+
│ ││╰─ attrValue.value "x &&=y"
513+
│ │├─ attrValue "=x &&=y"
514+
│ │╰─ attrName
515+
╰─ ╰─ tagName
517516
69╭─ <a=x |=y a/>
518-
│ ││││ │╰─ openTagEnd:selfClosed "/>"
519-
│ ││││ ╰─ attrName
520-
│ │││╰─ attrValue.value "x |=y"
521-
│ ││├─ attrValue "=x |=y"
522-
│ ││╰─ attrName
523-
│ │╰─ tagName
524-
╰─ ╰─ text "\n"
517+
│ │││ │╰─ openTagEnd:selfClosed "/>"
518+
│ │││ ╰─ attrName
519+
│ ││╰─ attrValue.value "x |=y"
520+
│ │├─ attrValue "=x |=y"
521+
│ │╰─ attrName
522+
╰─ ╰─ tagName
525523
70╭─ <a=x ||=y a/>
526-
│ ││││ │╰─ openTagEnd:selfClosed "/>"
527-
│ ││││ ╰─ attrName
528-
│ │││╰─ attrValue.value "x ||=y"
529-
│ ││├─ attrValue "=x ||=y"
530-
│ ││╰─ attrName
531-
│ │╰─ tagName
532-
╰─ ╰─ text "\n"
524+
│ │││ │╰─ openTagEnd:selfClosed "/>"
525+
│ │││ ╰─ attrName
526+
│ ││╰─ attrValue.value "x ||=y"
527+
│ │├─ attrValue "=x ||=y"
528+
│ │╰─ attrName
529+
╰─ ╰─ tagName
533530
71╭─ <a=x ^=y a/>
534-
│ ││││ │╰─ openTagEnd:selfClosed "/>"
535-
│ ││││ ╰─ attrName
536-
│ │││╰─ attrValue.value "x ^=y"
537-
│ ││├─ attrValue "=x ^=y"
538-
│ ││╰─ attrName
539-
│ │╰─ tagName
540-
╰─ ╰─ text "\n"
531+
│ │││ │╰─ openTagEnd:selfClosed "/>"
532+
│ │││ ╰─ attrName
533+
│ ││╰─ attrValue.value "x ^=y"
534+
│ │├─ attrValue "=x ^=y"
535+
│ │╰─ attrName
536+
╰─ ╰─ tagName
541537
72╭─ <a=x ~=y a/>
542-
│ ││││ │╰─ openTagEnd:selfClosed "/>"
543-
│ ││││ ╰─ attrName
544-
│ │││╰─ attrValue.value "x ~=y"
545-
│ ││├─ attrValue "=x ~=y"
546-
│ ││╰─ attrName
547-
│ │╰─ tagName
548-
╰─ ╰─ text "\n"
538+
│ │││ │╰─ openTagEnd:selfClosed "/>"
539+
│ │││ ╰─ attrName
540+
│ ││╰─ attrValue.value "x ~=y"
541+
│ │├─ attrValue "=x ~=y"
542+
│ │╰─ attrName
543+
╰─ ╰─ tagName
549544
73╭─ <a=x >>=y a/>
550-
│ ││││ │╰─ openTagEnd:selfClosed "/>"
551-
│ ││││ ╰─ attrName
552-
│ │││╰─ attrValue.value "x >>=y"
553-
│ ││├─ attrValue "=x >>=y"
554-
│ ││╰─ attrName
555-
│ │╰─ tagName
556-
╰─ ╰─ text "\n"
545+
│ │││ │╰─ openTagEnd:selfClosed "/>"
546+
│ │││ ╰─ attrName
547+
│ ││╰─ attrValue.value "x >>=y"
548+
│ │├─ attrValue "=x >>=y"
549+
│ │╰─ attrName
550+
╰─ ╰─ tagName
557551
74╭─ <a=x >>>=y a/>
558-
│ ││││ │╰─ openTagEnd:selfClosed "/>"
559-
│ ││││ ╰─ attrName
560-
│ │││╰─ attrValue.value "x >>>=y"
561-
│ ││├─ attrValue "=x >>>=y"
562-
│ ││╰─ attrName
563-
│ │╰─ tagName
564-
╰─ ╰─ text "\n"
552+
│ │││ │╰─ openTagEnd:selfClosed "/>"
553+
│ │││ ╰─ attrName
554+
│ ││╰─ attrValue.value "x >>>=y"
555+
│ │├─ attrValue "=x >>>=y"
556+
│ │╰─ attrName
557+
╰─ ╰─ tagName
565558
75╭─ <a=x -=y a/>
566-
│ ││││ │╰─ openTagEnd:selfClosed "/>"
567-
│ ││││ ╰─ attrName
568-
│ │││╰─ attrValue.value "x -=y"
569-
│ ││├─ attrValue "=x -=y"
570-
│ ││╰─ attrName
571-
│ │╰─ tagName
572-
╰─ ╰─ text "\n"
559+
│ │││ │╰─ openTagEnd:selfClosed "/>"
560+
│ │││ ╰─ attrName
561+
│ ││╰─ attrValue.value "x -=y"
562+
│ │├─ attrValue "=x -=y"
563+
│ │╰─ attrName
564+
╰─ ╰─ tagName
573565
76╭─ <a=x /=y a/>
574-
│ ││││ │╰─ openTagEnd:selfClosed "/>"
575-
│ ││││ ╰─ attrName
576-
│ │││╰─ attrValue.value "x /=y"
577-
│ ││├─ attrValue "=x /=y"
578-
│ ││╰─ attrName
579-
│ │╰─ tagName
580-
╰─ ╰─ text "\n"
566+
│ │││ │╰─ openTagEnd:selfClosed "/>"
567+
│ │││ ╰─ attrName
568+
│ ││╰─ attrValue.value "x /=y"
569+
│ │├─ attrValue "=x /=y"
570+
│ │╰─ attrName
571+
╰─ ╰─ tagName
581572
77╭─ <a=x *=y a/>
582-
│ ││││ │╰─ openTagEnd:selfClosed "/>"
583-
│ ││││ ╰─ attrName
584-
│ │││╰─ attrValue.value "x *=y"
585-
│ ││├─ attrValue "=x *=y"
586-
│ ││╰─ attrName
587-
│ │╰─ tagName
588-
╰─ ╰─ text "\n"
573+
│ │││ │╰─ openTagEnd:selfClosed "/>"
574+
│ │││ ╰─ attrName
575+
│ ││╰─ attrValue.value "x *=y"
576+
│ │├─ attrValue "=x *=y"
577+
│ │╰─ attrName
578+
╰─ ╰─ tagName
589579
78╭─ <a=x **=y a/>
590-
│ ││││ │╰─ openTagEnd:selfClosed "/>"
591-
│ ││││ ╰─ attrName
592-
│ │││╰─ attrValue.value "x **=y"
593-
│ ││├─ attrValue "=x **=y"
594-
│ ││╰─ attrName
595-
│ │╰─ tagName
596-
╰─ ╰─ text "\n"
580+
│ │││ │╰─ openTagEnd:selfClosed "/>"
581+
│ │││ ╰─ attrName
582+
│ ││╰─ attrValue.value "x **=y"
583+
│ │├─ attrValue "=x **=y"
584+
│ │╰─ attrName
585+
╰─ ╰─ tagName
597586
79╭─ <a=x %=y a/>
598-
│ ││││ │╰─ openTagEnd:selfClosed "/>"
599-
│ ││││ ╰─ attrName
600-
│ │││╰─ attrValue.value "x %=y"
601-
│ ││├─ attrValue "=x %=y"
602-
│ ││╰─ attrName
603-
│ │╰─ tagName
604-
╰─ ╰─ text "\n"
587+
│ │││ │╰─ openTagEnd:selfClosed "/>"
588+
│ │││ ╰─ attrName
589+
│ ││╰─ attrValue.value "x %=y"
590+
│ │├─ attrValue "=x %=y"
591+
│ │╰─ attrName
592+
╰─ ╰─ tagName
605593
80╭─ <a=x +=y a/>
606-
│ ││││ │╰─ openTagEnd:selfClosed "/>"
607-
│ ││││ ╰─ attrName
608-
│ │││╰─ attrValue.value "x +=y"
609-
│ ││├─ attrValue "=x +=y"
610-
│ ││╰─ attrName
611-
│ │╰─ tagName
612-
╰─ ╰─ text "\n"
594+
│ │││ │╰─ openTagEnd:selfClosed "/>"
595+
│ │││ ╰─ attrName
596+
│ ││╰─ attrValue.value "x +=y"
597+
│ │├─ attrValue "=x +=y"
598+
│ │╰─ attrName
599+
╰─ ╰─ tagName
613600
81╭─ <a=x++ +y a/>
614-
│ ││││ │╰─ openTagEnd:selfClosed "/>"
615-
│ ││││ ╰─ attrName
616-
│ │││╰─ attrValue.value "x++ +y"
617-
│ ││├─ attrValue "=x++ +y"
618-
│ ││╰─ attrName
619-
│ │╰─ tagName
620-
╰─ ╰─ text "\n"
601+
│ │││ │╰─ openTagEnd:selfClosed "/>"
602+
│ │││ ╰─ attrName
603+
│ ││╰─ attrValue.value "x++ +y"
604+
│ │├─ attrValue "=x++ +y"
605+
│ │╰─ attrName
606+
╰─ ╰─ tagName
621607
82╭─ <a=x+ ++y a/>
622-
│ ││││ │╰─ openTagEnd:selfClosed "/>"
623-
│ ││││ ╰─ attrName
624-
│ │││╰─ attrValue.value "x+ ++y"
625-
│ ││├─ attrValue "=x+ ++y"
626-
│ ││╰─ attrName
627-
│ │╰─ tagName
628-
╰─ ╰─ text "\n"
608+
│ │││ │╰─ openTagEnd:selfClosed "/>"
609+
│ │││ ╰─ attrName
610+
│ ││╰─ attrValue.value "x+ ++y"
611+
│ │├─ attrValue "=x+ ++y"
612+
│ │╰─ attrName
613+
╰─ ╰─ tagName
629614
83╭─ <a=x >y <a/>
630615
│ ││││ ││ │╰─ openTagEnd:selfClosed "/>"
631616
│ ││││ ││ ╰─ tagName
@@ -635,7 +620,7 @@
635620
│ ││├─ attrValue "=x"
636621
│ ││╰─ attrName
637622
│ │╰─ tagName
638-
╰─ ╰─ text "\n"
623+
╰─ ╰─ error(MISSING_END_TAG:Missing ending "a" tag) "<a=x >"
639624
84╭─ <a=x >>y a/>
640625
│ ││││ │╰─ openTagEnd:selfClosed "/>"
641626
│ ││││ ╰─ attrName
@@ -669,34 +654,36 @@
669654
│ │╰─ tagName
670655
╰─ ╰─ text "\n"
671656
88╭─ <a=x =>y a/>
672-
│ ││││ │╰─ text "y a/>\n"
673-
│ ││││ ╰─ openTagEnd
674-
│ │││╰─ attrValue.value "x ="
675-
│ ││├─ attrValue "=x ="
657+
│ ││││ │╰─ openTagEnd:selfClosed "/>"
658+
│ ││││ ╰─ attrName
659+
│ │││╰─ attrValue.value "x =>y"
660+
│ ││├─ attrValue "=x =>y"
676661
│ ││╰─ attrName
677662
│ │╰─ tagName
678663
╰─ ╰─ text "\n"
679664
89╭─ <a=x => (y ) a/>
680-
│ │││ │╰─ text " (y ) a/>\n"
681-
│ │││ ╰─ openTagEnd
682-
│ ││╰─ attrValue.value "x ="
683-
│ │├─ attrValue "=x ="
684-
│ │╰─ attrName
685-
╰─ ╰─ tagName
665+
│ ││││ │╰─ openTagEnd:selfClosed "/>"
666+
│ ││││ ╰─ attrName
667+
│ │││╰─ attrValue.value "x => (y )"
668+
│ ││├─ attrValue "=x => (y )"
669+
│ ││╰─ attrName
670+
│ │╰─ tagName
671+
╰─ ╰─ text "\n"
686672
90╭─ <a=x => {y } a/>
687-
│ ││││ │╰─ text " {y } a/>\n"
688-
│ ││││ ╰─ openTagEnd
689-
│ │││╰─ attrValue.value "x ="
690-
│ ││├─ attrValue "=x ="
673+
│ ││││ │╰─ openTagEnd:selfClosed "/>"
674+
│ ││││ ╰─ attrName
675+
│ │││╰─ attrValue.value "x => {y }"
676+
│ ││├─ attrValue "=x => {y }"
691677
│ ││╰─ attrName
692678
│ │╰─ tagName
693-
╰─ ╰─ error(MISSING_END_TAG:Missing ending "a" tag) "<a=x =>"
679+
╰─ ╰─ text "\n"
694680
91╭─ <a=( x ) {y } a/>
695-
│ │││ │╰─ openTagEnd:selfClosed "/>"
696-
│ │││ ╰─ attrName
697-
│ ││╰─ attrValue.value "( x ) {y }"
698-
│ │├─ attrValue "=( x ) {y }"
699-
│ │╰─ attrName
700-
╰─ ╰─ tagName
681+
│ ││││ │╰─ openTagEnd:selfClosed "/>"
682+
│ ││││ ╰─ attrName
683+
│ │││╰─ attrValue.value "( x ) {y }"
684+
│ ││├─ attrValue "=( x ) {y }"
685+
│ ││╰─ attrName
686+
│ │╰─ tagName
687+
╰─ ╰─ text "\n"
701688
92╭─
702689
╰─ ╰─ text "\n"

0 commit comments

Comments
 (0)