File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -519,7 +519,7 @@ protected function wrappedBy(ValidHtml $element)
519519 protected function isIntermediateWrapper (ValidHtml $ element ): bool
520520 {
521521 foreach ($ this ->content as $ child ) {
522- if ($ child instanceof self && $ child ->wrappedBy ($ element )) {
522+ if ($ child instanceof self && ( $ child ->wrappedBy ($ element) || $ child -> isIntermediateWrapper ( $ element ) )) {
523523 return true ;
524524 }
525525 }
Original file line number Diff line number Diff line change @@ -110,6 +110,34 @@ public function testTopLevelWrappersReferencedFromBelowAgain()
110110 );
111111 }
112112
113+ public function testMultipleReferencesToWrappedElementAreCorrectlyResolved (): void
114+ {
115+ $ a = h::tag ('a ' );
116+ $ b = h::tag ('b ' );
117+ $ c = h::tag ('c ' );
118+
119+ $ a ->prependWrapper ($ b ); // b -> a
120+ $ b ->addHtml ($ a );
121+
122+ // b
123+ // \
124+ // a
125+
126+ $ a ->addWrapper ($ c ); // c -> b -> a
127+ $ c ->addHtml (h::tag ('d ' , $ a ));
128+
129+ // c -> b
130+ // \ \
131+ // d a
132+ // \
133+ // a
134+
135+ $ this ->assertHtml (
136+ '<c><d><b><a></a></b></d></c> ' ,
137+ $ a
138+ );
139+ }
140+
113141 public function testWrapperLoopsAreDetected ()
114142 {
115143 $ a = h::tag ('a ' );
You can’t perform that action at this time.
0 commit comments