File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed
Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -114,7 +114,15 @@ export default class HtmlDiff {
114114 // no need to diff
115115 if ( oldHtml === newHtml ) {
116116 this . unifiedContent = oldHtml
117- this . sideBySideContents = [ oldHtml , newHtml ]
117+ let equalSequence = 0
118+ const content = oldHtml . replace (
119+ / < ( [ ^ \s / > ] + ) [ ^ > ] * > / g,
120+ ( match : string , name : string ) => {
121+ const tagNameLength = name . length + 1
122+ return `${ match . slice ( 0 , tagNameLength ) } data-seq="${ ++ equalSequence } "${ match . slice ( tagNameLength ) } `
123+ } ,
124+ )
125+ this . sideBySideContents = [ content , content ]
118126 return
119127 }
120128
Original file line number Diff line number Diff line change @@ -104,10 +104,10 @@ exports[`HtmlDiff > should work with equal 1`] = `
104104
105105exports[`HtmlDiff > should work with equal 2`] = `
106106[
107- "<h1 >hello world</h1 >
108- <p >你若安好,便是晴天</p >",
109- "<h1 >hello world</h1 >
110- <p >你若安好,便是晴天</p >",
107+ "<h1 data-seq = " 1 " >hello world</h1 >
108+ <p data-seq = " 2 " >你若安好,便是晴天</p >",
109+ "<h1 data-seq = " 1 " >hello world</h1 >
110+ <p data-seq = " 2 " >你若安好,便是晴天</p >",
111111]
112112`;
113113
You can’t perform that action at this time.
0 commit comments