Subramanya Sastry has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/95708


Change subject: WIP: Suppress harmless DSR inconsistency warnings
......................................................................

WIP: Suppress harmless DSR inconsistency warnings

* Added 1 scenario which suppresses 6 warnings.
* More to be added.

Change-Id: I65e9b93e72453b006c817cb2d880e40234b0bf26
---
M js/lib/dom.computeDSR.js
1 file changed, 20 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid 
refs/changes/08/95708/1

diff --git a/js/lib/dom.computeDSR.js b/js/lib/dom.computeDSR.js
index ff4f287..9e62fc8 100644
--- a/js/lib/dom.computeDSR.js
+++ b/js/lib/dom.computeDSR.js
@@ -24,6 +24,25 @@
                (dp.stx === "url" || dp.stx === "protocol");
 }
 
+function acceptableInconsistency(node, cs, s) {
+       /**
+        * 1. For wikitext URL links, suppress cs-s diff warnings because
+        *    the diffs can come about because of various reasions since the
+        *    canonicalized/decoded href will become the a-link text whose width
+        *    will not match the tsr width of source wikitext
+        *
+        *    (a) urls with encoded chars (ex: 
'http://example.com/?foo=bar')
+        *    (b) non-canonical spaces (ex: 'RFC  123' instead of 'RFC 123')
+        *
+        * 2. Other scenarios .. to be added
+        */
+       if (node.nodeName === 'A' && usesURLLinkSyntax(node, 
node.data.parsoid)) {
+               return true;
+       } else {
+               return false;
+       }
+}
+
 /* ------------------------------------------------------------------------
  * TSR = "Tag Source Range".  Start and end offsets giving the location
  * where the tag showed up in the original source.
@@ -502,7 +521,7 @@
        }
 
        // Detect errors
-       if (s !== null && s !== undefined && cs !== s) {
+       if (s !== null && s !== undefined && cs !== s && 
!acceptableInconsistency(node, cs, s)) {
                console.warn("WARNING: DSR inconsistency: cs/s mismatch for 
node: " +
                        node.nodeName + " s: " + s + "; cs: " + cs);
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/95708
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I65e9b93e72453b006c817cb2d880e40234b0bf26
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to