Skip to content

Commit fc8748b

Browse files
committed
Merge branch 't/12308'
2 parents 24b4fc5 + 11edde3 commit fc8748b

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

core/dom/iterator.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,12 @@
370370
// Because information about line break will be lost when shrinking range.
371371
// Note that we test only if path block exist, because we must properly shrink
372372
// range containing table and/or table cells.
373+
// Note: When range is collapsed there's no way it can be shrinked.
374+
// By checking if range is collapsed we also prevent #12308.
373375
startPath = range.startPath(),
374376
endPath = range.endPath(),
375-
startAtInnerBoundary = rangeAtInnerBlockBoundary( range, startPath.block ),
376-
endAtInnerBoundary = rangeAtInnerBlockBoundary( range, endPath.block, 1 );
377+
startAtInnerBoundary = !range.collapsed && rangeAtInnerBlockBoundary( range, startPath.block ),
378+
endAtInnerBoundary = !range.collapsed && rangeAtInnerBlockBoundary( range, endPath.block, 1 );
377379

378380
// Shrink the range to exclude harmful "noises" (#4087, #4450, #5435).
379381
range.shrink( CKEDITOR.SHRINK_ELEMENT, true );

tests/core/dom/iterator.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,15 @@ bender.test( {
152152
assert.areSame( 'h1,p', iterateWithRangeIterator( ranges ).join( ',' ) );
153153
},
154154

155+
// #12308 (Note: this test wasn't able to verify #12308's patch, but it makes sense anyway).
156+
'test iterating at block boundary - before bogus br': function() {
157+
if ( !CKEDITOR.env.needsBrFiller )
158+
assert.ignore();
159+
160+
var source = '<h1>para1^<br /></h1><p>para2</p>';
161+
checkRangeIteration( source, null, [ 'h1' ], null, 'Iteration will yield heading.' );
162+
},
163+
155164
'test iterating over pseudo block': function() {
156165
var source = '<div><p>[paragraph</p>text]</div>';
157166
var output = '<div><p>paragraph</p><p>text</p></div>';

0 commit comments

Comments
 (0)