There was no check if anchorNode of selection range is inside an element with CSS class ve-ce-slug.

Adding that check let me simplify logic around a little bit as well.

Bug: 47258

Change-Id: I51bf5e9caecf6a8b4e0f75118a93cfe69a5a6542
This commit is contained in:
Inez Korczyński 2013-04-15 13:49:49 -07:00 committed by Trevor Parscal
parent 887465b159
commit 097fd3c1a4

View file

@ -126,7 +126,7 @@ ve.ce.SurfaceObserver.prototype.stop = function ( poll ) {
* @emits selectionChange
*/
ve.ce.SurfaceObserver.prototype.poll = function ( async ) {
var delayPoll, $branch, node, text, hash, range, rangyRange;
var delayPoll, $nodeOrSlug, node, text, hash, range, rangyRange;
if ( this.polling === false ) {
return;
@ -155,13 +155,12 @@ ve.ce.SurfaceObserver.prototype.poll = function ( async ) {
if ( !rangyRange.equals( this.rangyRange ) ){
this.rangyRange = rangyRange;
$branch = $( rangyRange.anchorNode ).closest( '.ve-ce-branchNode' );
if ( $branch.length ) {
node = $branch.data( 'view' );
if ( node.canHaveChildrenNotContent() ) {
node = null;
} else {
range = rangyRange.getRange();
node = null;
$nodeOrSlug = $( rangyRange.anchorNode ).closest( '.ve-ce-branchNode, .ve-ce-slug' );
if ( $nodeOrSlug.length ) {
range = rangyRange.getRange();
if ( !$nodeOrSlug.hasClass( 've-ce-slug' ) ) {
node = $nodeOrSlug.data( 'view' );
}
}
}