jenkins-bot has submitted this change and it was merged.

Change subject: Use indexes in .children, not .childNodes, for attribute 
preservation
......................................................................


Use indexes in .children, not .childNodes, for attribute preservation

The difference is that .children excludes non-element nodes (text nodes
and comment nodes). These can't have attributes anyway, so there's
nothing lost by skipping them, and this way we avoid bugs where a
text node split causes the indexes to be off.

(Text node splits are probably due to an interaction between whitespace
preservation and paragraph unwrapping, and aren't necessarily bad. We
just shouldn't rely on indexes into .childNodes)

Change-Id: I905a50e1c299ebafcbd4eaa0f938b06a1b5849ff
---
M modules/ve/dm/ve.dm.Converter.js
1 file changed, 5 insertions(+), 2 deletions(-)

Approvals:
  Krinkle: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/ve/dm/ve.dm.Converter.js b/modules/ve/dm/ve.dm.Converter.js
index d64465a..90f4701 100644
--- a/modules/ve/dm/ve.dm.Converter.js
+++ b/modules/ve/dm/ve.dm.Converter.js
@@ -129,7 +129,10 @@
                if ( deep ) {
                        attributeList[i].children = [];
                        childList = ve.dm.Converter.buildHtmlAttributeList(
-                               domElements[i].childNodes, spec, deep, 
attributeList[i].children
+                               // Use .children rather than .childNodes so we 
don't mess around with things that
+                               // can't have attributes anyway. Unfortunately, 
non-element nodes have .children
+                               // set to undefined so we have to coerce it to 
an array in that case.
+                               domElements[i].children || [], spec, deep, 
attributeList[i].children
                        );
                        if ( childList ) {
                                empty = false;
@@ -177,7 +180,7 @@
                }
                if ( attributeList[i].children ) {
                        ve.dm.Converter.renderHtmlAttributeList(
-                               attributeList[i].children, 
domElements[i].childNodes, spec
+                               attributeList[i].children, 
domElements[i].children, spec
                        );
                }
        }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I905a50e1c299ebafcbd4eaa0f938b06a1b5849ff
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to