Small clean up.

Added variables for element, editor, and preview during initialisation.
This commit is contained in:
Pouria Hadjibagheri 2017-07-07 10:53:42 +01:00 committed by GitHub
parent 50c730b9a4
commit f2036f6993

View file

@ -831,17 +831,14 @@ docReady(() => {
const ELEMENTS = document.getElementsByClassName('markdownx');
return Object.keys(ELEMENTS).map(key => {
// Only add the new MarkdownX instance to fields that have no MarkdownX instance yet
if (!ELEMENTS[key].querySelector('.markdownx-editor').hasAttribute('data-markdownx-init')) {
return new MarkdownX(
ELEMENTS[key],
ELEMENTS[key].querySelector('.markdownx-editor'),
ELEMENTS[key].querySelector('.markdownx-preview')
)
}
let element = ELEMENTS[key],
editor = element.querySelector('.markdownx-editor'),
preview = element.querySelector('.markdownx-preview');
// Only add the new MarkdownX instance to fields that have no MarkdownX instance yet.
if (!editor.hasAttribute('data-markdownx-init'))
return new MarkdownX(element, editor, preview)
});