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

Change subject: Move sluggability methods to model
......................................................................


Move sluggability methods to model

Change-Id: Ie189979baae202572bdf8936c9431b8b49f55d35
---
M src/ce/nodes/ve.ce.ListNode.js
M src/ce/ve.ce.BranchNode.js
M src/ce/ve.ce.Node.js
M src/dm/nodes/ve.dm.ListNode.js
M src/dm/ve.dm.Node.js
5 files changed, 36 insertions(+), 42 deletions(-)

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



diff --git a/src/ce/nodes/ve.ce.ListNode.js b/src/ce/nodes/ve.ce.ListNode.js
index 7733e0c..da76341 100644
--- a/src/ce/nodes/ve.ce.ListNode.js
+++ b/src/ce/nodes/ve.ce.ListNode.js
@@ -61,22 +61,6 @@
        this.updateTagName();
 };
 
-/**
- * Check if a slug be placed after the node.
- *
- * @method
- * @returns {boolean} A slug can be placed after the node
- */
-ve.ce.ListNode.prototype.canHaveSlugAfter = function () {
-       if ( this.getParent().getType() === 'listItem' ) {
-               // Nested lists should not have slugs after them
-               return false;
-       } else {
-               // Parent method
-               return ve.ce.BranchNode.prototype.canHaveSlugAfter.call( this );
-       }
-};
-
 /* Registration */
 
 ve.ce.nodeFactory.register( ve.ce.ListNode );
diff --git a/src/ce/ve.ce.BranchNode.js b/src/ce/ve.ce.BranchNode.js
index 66e04a6..6884f85 100644
--- a/src/ce/ve.ce.BranchNode.js
+++ b/src/ce/ve.ce.BranchNode.js
@@ -255,17 +255,17 @@
                                continue;
                        }
                        // First sluggable child (left side)
-                       if ( i === 0 && this.children[i].canHaveSlugBefore() ) {
+                       if ( i === 0 && 
this.children[i].getModel().canHaveSlugBefore() ) {
                                this.slugs[i] = doc.importNode( slug, true );
                                first = this.children[i].$element[0];
                                first.parentNode.insertBefore( this.slugs[i], 
first );
                        }
-                       if ( this.children[i].canHaveSlugAfter() ) {
+                       if ( this.children[i].getModel().canHaveSlugAfter() ) {
                                if (
                                        // Last sluggable child (right side)
                                        i === this.children.length - 1 ||
                                        // Sluggable child followed by another 
sluggable child (in between)
-                                       ( this.children[i + 1] && 
this.children[i + 1].canHaveSlugBefore() )
+                                       ( this.children[i + 1] && 
this.children[i + 1].getModel().canHaveSlugBefore() )
                                ) {
                                        this.slugs[i + 1] = doc.importNode( 
slug, true );
                                        last = 
this.children[i].$element[this.children[i].$element.length - 1];
diff --git a/src/ce/ve.ce.Node.js b/src/ce/ve.ce.Node.js
index 8cc5d8f..e885ea2 100644
--- a/src/ce/ve.ce.Node.js
+++ b/src/ce/ve.ce.Node.js
@@ -177,29 +177,6 @@
 };
 
 /**
- * Check if the node can have a slug before it.
- *
- * TODO: Figure out a way to remove the hard-coding for text nodes here.
- *
- * @method
- * @returns {boolean} Whether the node can have a slug before it
- */
-ve.ce.Node.prototype.canHaveSlugBefore = function () {
-       return !this.canContainContent() &&
-               this.getParentNodeTypes() === null &&
-               this.type !== 'text' &&
-               this.type !== 'list';
-};
-
-/**
- * Check if the node can have a slug after it.
- *
- * @method
- * @returns {boolean} Whether the node can have a slug after it
- */
-ve.ce.Node.prototype.canHaveSlugAfter = ve.ce.Node.prototype.canHaveSlugBefore;
-
-/**
  * Get the length of the node.
  *
  * This method passes through to the model.
diff --git a/src/dm/nodes/ve.dm.ListNode.js b/src/dm/nodes/ve.dm.ListNode.js
index a0d672d..310a55d 100644
--- a/src/dm/nodes/ve.dm.ListNode.js
+++ b/src/dm/nodes/ve.dm.ListNode.js
@@ -46,6 +46,16 @@
        return [ doc.createElement( tag ) ];
 };
 
+ve.dm.ListNode.prototype.canHaveSlugAfter = function () {
+       if ( this.getParent().getType() === 'listItem' ) {
+               // Nested lists should not have slugs after them
+               return false;
+       } else {
+               // Parent method
+               return ve.dm.BranchNode.prototype.canHaveSlugAfter.call( this );
+       }
+};
+
 /* Registration */
 
 ve.dm.modelRegistry.register( ve.dm.ListNode );
diff --git a/src/dm/ve.dm.Node.js b/src/dm/ve.dm.Node.js
index f2921ff..9d318dc 100644
--- a/src/dm/ve.dm.Node.js
+++ b/src/dm/ve.dm.Node.js
@@ -378,6 +378,29 @@
 };
 
 /**
+ * Check if the node can have a slug before it.
+ *
+ * TODO: Figure out a way to remove the hard-coding for text nodes here.
+ *
+ * @method
+ * @returns {boolean} Whether the node can have a slug before it
+ */
+ve.dm.Node.prototype.canHaveSlugBefore = function () {
+       return !this.canContainContent() &&
+               this.getParentNodeTypes() === null &&
+               this.type !== 'text' &&
+               this.type !== 'list';
+};
+
+/**
+ * Check if the node can have a slug after it.
+ *
+ * @method
+ * @returns {boolean} Whether the node can have a slug after it
+ */
+ve.dm.Node.prototype.canHaveSlugAfter = ve.dm.Node.prototype.canHaveSlugBefore;
+
+/**
  * Check if the node has significant whitespace.
  *
  * Can only be true if canContainContent is also true.

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

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

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

Reply via email to