Fix for ve.ce.BranchNode.setupSlugs - insert each slug only once

When using jQuery insertBefore and insertAfter make sure to pass as a parameter jQuery selection of only one element (first for insertBefore and last for insertAfter).

Change-Id: Id469ed775642ab5be8e274ab3cb7730899e9487a
This commit is contained in:
Inez Korczyński 2012-11-12 15:31:23 -08:00
parent 411b31cc93
commit 27ddb456c8

View file

@ -208,7 +208,7 @@ ve.ce.BranchNode.prototype.setupSlugs = function () {
for ( i = 0; i < this.children.length; i++ ) {
// First sluggable child (left side)
if ( i === 0 && this.children[i].canHaveSlugBefore() ) {
this.slugs[i] = $slug.clone().insertBefore( this.children[i].$ );
this.slugs[i] = $slug.clone().insertBefore( this.children[i].$.first() );
}
if ( this.children[i].canHaveSlugAfter() ) {
if (
@ -217,7 +217,7 @@ ve.ce.BranchNode.prototype.setupSlugs = function () {
// Sluggable child followed by another sluggable child (in between)
( this.children[i + 1] && this.children[i + 1].canHaveSlugBefore() )
) {
this.slugs[i + 1] = $slug.clone().insertAfter( this.children[i].$ );
this.slugs[i + 1] = $slug.clone().insertAfter( this.children[i].$.last() );
}
}
}