Page MenuHomePhabricator

Switch to using isContentEditable instead of contentEditable
Closed, ResolvedPublic8 Estimated Story Points

Description

Checking node.contentEditable has drawbacks:

  • it doesn't account for inheritance, if contentEditable="inherit" is being used
  • it's a string value, which people sometimes forget (see: T114545)
  • it requires something like $focusNode.closest( '[contenteditable]' ) anywhere it's checked,

Apparently in the past isContentEditable had problems, but @Krinkle tested it out in T114545 and didn't find any of them remaining in our currently supported browsers.

So, switch everywhere using the currently closest-contenteditable check to use isContentEditable instead. It needs to account for text nodes not having this property, so some helper function might make sense...

function isContentEditable( node ) {
    return ( node.nodeType === Node.TEXT_NODE ? node.parentNode : node ).isContentEditable;
}

Event Timeline

DLynch raised the priority of this task from to Needs Triage.
DLynch updated the task description. (Show Details)
DLynch added subscribers: DLynch, Esanders, Krinkle.
Jdforrester-WMF set Security to None.
Jdforrester-WMF edited a custom field.
Jdforrester-WMF moved this task from To Triage to TR3: Language support on the VisualEditor board.

Change 266265 had a related patch set uploaded (by DLynch):
Remove uses of plain .contentEditable

https://gerrit.wikimedia.org/r/266265

Change 266265 merged by jenkins-bot:
Remove uses of plain .contentEditable

https://gerrit.wikimedia.org/r/266265