Ticket #1559 (closed defect: fixed)
DefinitionList <dl> button errors if cursor context is <body> elem
| Reported by: | ejucovy | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.97 |
| Component: | Plugins | Version: | trunk |
| Severity: | normal | Keywords: | |
| Cc: |
Description
If the user presses the <dl> button (from the DefinitionList plugin) when the current context is text directly in the <body> element, the plugin throws a Javascript error:
Uncaught TypeError: Cannot call method 'toLowerCase' of undefined
The easiest way to reproduce is to click the button on an empty document, or on a document where you have typed text but never pressed enter.
The problem is that the plugin assumes that the current selection's parent element is a child of the body element:
var pe = editor.getParentElement();
while (pe.parentNode.tagName.toLowerCase() != 'body') {
pe = pe.parentNode;
}
If editor.getParentElement() *is* the body element, this loop will walk up past it and end up at a node with no .parentElement.
The fix is to change the while loop's condition to
while (pe.tagName.toLowerCase() != 'body')
