@@ -85,6 +85,18 @@ class ListDiff extends HtmlDiff
85
85
* @var array
86
86
*/
87
87
protected $ diffOrderIndex = array ();
88
+
89
+ /**
90
+ * This is the opening ol,ul,dl ist tag.
91
+ * @var string
92
+ */
93
+ protected $ oldParentTag ;
94
+
95
+ /**
96
+ * This is the opening ol,ul,dl ist tag.
97
+ * @var string
98
+ */
99
+ protected $ newParentTag ;
88
100
89
101
/**
90
102
* We're using the same functions as the parent in build() to get us to the point of
@@ -232,10 +244,12 @@ protected function formatList(array $arrayData, $index = 'old')
232
244
array_key_exists ($ closingTag , $ this ->isolatedDiffTags )
233
245
) {
234
246
if ($ index == 'new ' && $ this ->isOpeningTag ($ arrayData [0 ])) {
247
+ $ this ->newParentTag = $ arrayData [0 ];
235
248
$ this ->newListType = $ this ->getAndStripTag ($ arrayData [0 ]);
236
249
}
237
250
238
251
if ($ index == 'old ' && $ this ->isOpeningTag ($ arrayData [0 ])) {
252
+ $ this ->oldParentTag = $ arrayData [0 ];
239
253
$ this ->oldListType = $ this ->getAndStripTag ($ arrayData [0 ]);
240
254
}
241
255
@@ -448,13 +462,13 @@ protected function diff()
448
462
if ($ oldMatch && $ oldMatch ['new ' ] === null ) {
449
463
$ newList = '' ;
450
464
$ oldList = $ this ->getListByMatch ($ oldMatch , 'old ' );
451
- $ this ->content .= $ this ->addListElementToContent ($ newList , $ oldList , $ oldMatch );
465
+ $ this ->content .= $ this ->addListElementToContent ($ newList , $ oldList , $ oldMatch, $ index , ' old ' );
452
466
}
453
467
454
468
$ match = $ this ->getArrayByColumnValue ($ this ->textMatches , 'new ' , $ index ['position ' ]);
455
469
$ newList = $ this ->childLists ['new ' ][$ match ['new ' ]];
456
470
$ oldList = $ this ->getListByMatch ($ match , 'old ' );
457
- $ this ->content .= $ this ->addListElementToContent ($ newList , $ oldList , $ match );
471
+ $ this ->content .= $ this ->addListElementToContent ($ newList , $ oldList , $ match, $ index , ' new ' );
458
472
}
459
473
460
474
if ($ index ['type ' ] == 'content ' ) {
@@ -471,7 +485,7 @@ protected function diff()
471
485
if ($ oldMatch && $ oldMatch ['new ' ] === null ) {
472
486
$ newList = '' ;
473
487
$ oldList = $ this ->getListByMatch ($ oldMatch , 'old ' );
474
- $ this ->content .= $ this ->addListElementToContent ($ newList , $ oldList , $ oldMatch );
488
+ $ this ->content .= $ this ->addListElementToContent ($ newList , $ oldList , $ oldMatch, $ oldIndex , ' old ' );
475
489
}
476
490
} else {
477
491
$ this ->content .= $ this ->addContentElementsToContent ($ oldKey );
@@ -490,11 +504,12 @@ protected function diff()
490
504
* @param string $newList
491
505
* @param string $oldList
492
506
* @param array $match
507
+ * @param array $index
493
508
* @return string
494
509
*/
495
- protected function addListElementToContent ($ newList , $ oldList , array $ match )
510
+ protected function addListElementToContent ($ newList , $ oldList , array $ match, array $ index , $ type )
496
511
{
497
- $ content = " <li> " ;
512
+ $ content = $ this -> list [ $ type ][ $ index [ ' index ' ]] ;
498
513
$ content .= $ this ->processPlaceholders (
499
514
$ this ->diffElements (
500
515
$ this ->convertListContentArrayToString ($ oldList ),
@@ -768,7 +783,12 @@ protected function indexLists()
768
783
*/
769
784
protected function addListTypeWrapper ($ opening = true )
770
785
{
771
- return "< " . (!$ opening ? "/ " : '' ) . $ this ->listType . "> " ;
786
+
787
+ if ($ opening ) {
788
+ return $ this ->newParentTag ?: $ this ->oldParentTag ;
789
+ } else {
790
+ return "< " . (!$ opening ? "/ " : '' ) . $ this ->listType . "> " ;
791
+ }
772
792
}
773
793
774
794
/**
0 commit comments