-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix/1273: Fix child node length checks #2532
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2532 +/- ##
======================================
Coverage 30.1% 30.1%
======================================
Files 174 174
Lines 5288 5288
Branches 905 905
======================================
Hits 1592 1592
Misses 3133 3133
Partials 563 563
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Presumably this won't work if the caret is within an empty element which is the fourth child of its body? Wondering if this is something we'd want to use recursion or loops, like in Editable:
gutenberg/blocks/editable/index.js
Lines 247 to 263 in ec49b3d
isStartOfEditor() { | |
const range = this.editor.selection.getRng(); | |
if ( range.startOffset !== 0 || ! range.collapsed ) { | |
return false; | |
} | |
const start = range.startContainer; | |
const body = this.editor.getBody(); | |
let element = start; | |
while ( element !== body ) { | |
const child = element; | |
element = element.parentNode; | |
if ( element.firstChild !== child ) { | |
return false; | |
} | |
} | |
return true; | |
} |
Or @iseulde's suggestion at #2482 (comment)
@aduth can you give an example of the content that could produce such an effect? For example if I artifiically set the content to contain a span like: The closest I can get to the situation you describe is by toggling on 'bold' in which case the first backspace removes the bold formatting (a behaviour I think is actually good). |
Okay, on second glance, I see you're testing against the specific pattern of
|
Fixes a typo in the previous pull request #2482 (review)