jenkins-bot has submitted this change and it was merged. Change subject: T125419: Fix selser issues serializing first table row ......................................................................
T125419: Fix selser issues serializing first table row * This is another instance of the 'chameleon node' effect as in 7608aeab. * Added new parser test that fails without this patch and passes with this patch. Change-Id: Icef41bed2e2bfe81429556d1e32f9b4e8017a5c1 --- M lib/html2wt/WTSUtils.js M tests/parserTests.txt 2 files changed, 29 insertions(+), 0 deletions(-) Approvals: Arlolra: Looks good to me, approved jenkins-bot: Verified diff --git a/lib/html2wt/WTSUtils.js b/lib/html2wt/WTSUtils.js index 68a787c..77bae2f 100644 --- a/lib/html2wt/WTSUtils.js +++ b/lib/html2wt/WTSUtils.js @@ -89,6 +89,14 @@ // showed up on the same line via the "||" or "!!" syntax, nothing // to worry about. return DU.getDataParsoid(node).stx_v !== 'row'; + } else if (node.nodeName === 'TR' && !DU.getDataParsoid(node).startTagSrc) { + // If this <tr> didn't have a startTagSrc, it would have been + // the first row of a table in original wikitext. So, it is safe + // to reuse the original source for the row (without a "|-") as long as + // it continues to be the first row of the table. If not, since we need to + // insert a "|-" to separate it from the newly added row (in an edit), + // we cannot simply reuse orig. wikitext for this <tr>. + return !DU.previousNonSepSibling(node); } else if (DU.isNestedListOrListItem(node)) { // If there are no previous siblings, bullets were assigned to // containing elements in the ext.core.ListHandler. For example, diff --git a/tests/parserTests.txt b/tests/parserTests.txt index 523953c..b6a857a 100644 --- a/tests/parserTests.txt +++ b/tests/parserTests.txt @@ -7161,6 +7161,27 @@ |} !!end +!! test +Testing selser after addition of new row before first row (T125419) +!! options +parsoid={ + "modes": ["wt2wt", "selser"], + "changes": [ + [ "tr", "before", "<tr><td>X</td></tr>" ] + ] +} +!! wikitext +{| +|a +|} +!! wikitext/edited +{| +|X +|- +|a +|} +!! end + ### ### Internal links ### -- To view, visit https://gerrit.wikimedia.org/r/291388 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Icef41bed2e2bfe81429556d1e32f9b4e8017a5c1 Gerrit-PatchSet: 6 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: Subramanya Sastry <ssas...@wikimedia.org> Gerrit-Reviewer: Arlolra <abrea...@wikimedia.org> Gerrit-Reviewer: Cscott <canan...@wikimedia.org> Gerrit-Reviewer: Subramanya Sastry <ssas...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits