Fossil SCM

Diff context loading: replaced string.replaceAll() with a more portable construct, as reported in [forum:c1f198f6993cd603 | forum post c1f198f6993cd603].

stephan 2021-09-22 03:04 trunk
Commit 48887195881200aea08df9050d467c3f9498cfc9d821859595f2f4bf72607598
1 file changed +8 -4
--- src/fossil.diff.js
+++ src/fossil.diff.js
@@ -314,14 +314,18 @@
314314
) ? trNext : false
315315
/* Truthy if we want to combine trPrev, the new content, and
316316
trNext into trPrev and then remove trNext. */;
317317
let i, td;
318318
if(!f.convertLines){
319
+ /* Reminder: string.replaceAll() is a relatively new
320
+ JS feature, not available in some still-widely-used
321
+ browser versions. */
322
+ f.rx = [[/&/g, '&amp;'], [/</g, '&lt;']];
319323
f.convertLines = function(li){
320
- return li.join('\n')
321
- .replaceAll('&','&amp;')
322
- .replaceAll('<','&lt;')+'\n';
324
+ var s = li.join('\n');
325
+ f.rx.forEach((a)=>s=s.replace(a[0],a[1]));
326
+ return s + '\n';
323327
};
324328
}
325329
if(1){ // LHS line numbers...
326330
const selector = '.difflnl > pre';
327331
td = tr.querySelector(selector);
@@ -343,11 +347,11 @@
343347
344348
if(1){// code block(s)...
345349
const selector = '.difftxt > pre';
346350
td = tr.querySelectorAll(selector);
347351
const code = f.convertLines(lines);
348
- let joinNdx = 0;
352
+ let joinNdx = 0/*selector[X] index to join together*/;
349353
td.forEach(function(e){
350354
const content = [e.innerHTML];
351355
if(doAppend) content.push(code);
352356
else content.unshift(code);
353357
if(joinTr){
354358
--- src/fossil.diff.js
+++ src/fossil.diff.js
@@ -314,14 +314,18 @@
314 ) ? trNext : false
315 /* Truthy if we want to combine trPrev, the new content, and
316 trNext into trPrev and then remove trNext. */;
317 let i, td;
318 if(!f.convertLines){
 
 
 
 
319 f.convertLines = function(li){
320 return li.join('\n')
321 .replaceAll('&','&amp;')
322 .replaceAll('<','&lt;')+'\n';
323 };
324 }
325 if(1){ // LHS line numbers...
326 const selector = '.difflnl > pre';
327 td = tr.querySelector(selector);
@@ -343,11 +347,11 @@
343
344 if(1){// code block(s)...
345 const selector = '.difftxt > pre';
346 td = tr.querySelectorAll(selector);
347 const code = f.convertLines(lines);
348 let joinNdx = 0;
349 td.forEach(function(e){
350 const content = [e.innerHTML];
351 if(doAppend) content.push(code);
352 else content.unshift(code);
353 if(joinTr){
354
--- src/fossil.diff.js
+++ src/fossil.diff.js
@@ -314,14 +314,18 @@
314 ) ? trNext : false
315 /* Truthy if we want to combine trPrev, the new content, and
316 trNext into trPrev and then remove trNext. */;
317 let i, td;
318 if(!f.convertLines){
319 /* Reminder: string.replaceAll() is a relatively new
320 JS feature, not available in some still-widely-used
321 browser versions. */
322 f.rx = [[/&/g, '&amp;'], [/</g, '&lt;']];
323 f.convertLines = function(li){
324 var s = li.join('\n');
325 f.rx.forEach((a)=>s=s.replace(a[0],a[1]));
326 return s + '\n';
327 };
328 }
329 if(1){ // LHS line numbers...
330 const selector = '.difflnl > pre';
331 td = tr.querySelector(selector);
@@ -343,11 +347,11 @@
347
348 if(1){// code block(s)...
349 const selector = '.difftxt > pre';
350 td = tr.querySelectorAll(selector);
351 const code = f.convertLines(lines);
352 let joinNdx = 0/*selector[X] index to join together*/;
353 td.forEach(function(e){
354 const content = [e.innerHTML];
355 if(doAppend) content.push(code);
356 else content.unshift(code);
357 if(joinTr){
358

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button