ce.BranchNode: Insert slugs based on CE children length, not DM

Due to Firefox' Ctrl-A creating an outer selection (0,len) as
opposed to inner select like in Chrome (1,len-1), deleting leaves
the document completely empty (with no cursor anywhere in the
document).

However, setupSlugs() wasn't inserting a slug because the internal
list still existed (so this.model.length !== 0).

Using this.$.children().length instead.

Bug: 50947
Change-Id: I1517ebcc5b31e2544559b851174482b0c872b24b
This commit is contained in:
Timo Tijhof 2013-09-27 21:15:10 +02:00 committed by Roan Kattouw
parent 7849be8ec0
commit 9b99962215

View file

@ -227,7 +227,11 @@ ve.ce.BranchNode.prototype.setupSlugs = function () {
slug = ve.ce.BranchNode.$inlineSlugTemplate[0];
}
if ( this.getLength() === 0 ) {
// If this content branch no longer has any rendered children, insert a slug to keep the node
// from becoming invisible/unfocusable. In Firefox, backspace after Ctrl-A leaves the document
// completely empty, so this ensures DocumentNode gets a slug.
// Can't use this.getLength() because the internal list adds to the length but doesn't render.
if ( this.$.children().length === 0 ) {
this.slugs[0] = doc.importNode( slug, true );
this.$[0].appendChild( this.slugs[0] );
} else {