1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

use _.forEach instead of Array.prototype.forEach.call

This commit is contained in:
Dick Choi
2016-10-26 10:47:51 +09:00
parent b18a5be940
commit 12453942c8

View File

@@ -20,6 +20,7 @@ function decodeHTMLEntities (text) {
return text return text
} }
const { remote } = require('electron') const { remote } = require('electron')
const { app } = remote const { app } = remote
const path = require('path') const path = require('path')
@@ -175,10 +176,10 @@ export default class MarkdownPreview extends React.Component {
} }
rewriteIframe () { rewriteIframe () {
Array.prototype.forEach.call(this.refs.root.contentWindow.document.querySelectorAll('a'), (el) => { _.forEach(this.refs.root.contentWindow.document.querySelectorAll('a'), (el) => {
el.removeEventListener('click', this.anchorClickHandler) el.removeEventListener('click', this.anchorClickHandler)
}) })
Array.prototype.forEach.call(this.refs.root.contentWindow.document.querySelectorAll('input[type="checkbox"]'), (el) => { _.forEach(this.refs.root.contentWindow.document.querySelectorAll('input[type="checkbox"]'), (el) => {
el.removeEventListener('click', this.checkboxClickHandler) el.removeEventListener('click', this.checkboxClickHandler)
}) })
@@ -187,11 +188,11 @@ export default class MarkdownPreview extends React.Component {
this.refs.root.contentWindow.document.body.setAttribute('data-theme', theme) this.refs.root.contentWindow.document.body.setAttribute('data-theme', theme)
this.refs.root.contentWindow.document.body.innerHTML = markdown.render(value) this.refs.root.contentWindow.document.body.innerHTML = markdown.render(value)
Array.prototype.forEach.call(this.refs.root.contentWindow.document.querySelectorAll('a'), (el) => { _.forEach(this.refs.root.contentWindow.document.querySelectorAll('a'), (el) => {
el.addEventListener('click', this.anchorClickHandler) el.addEventListener('click', this.anchorClickHandler)
}) })
Array.prototype.forEach.call(this.refs.root.contentWindow.document.querySelectorAll('input[type="checkbox"]'), (el) => { _.forEach(this.refs.root.contentWindow.document.querySelectorAll('input[type="checkbox"]'), (el) => {
el.addEventListener('click', this.checkboxClickHandler) el.addEventListener('click', this.checkboxClickHandler)
}) })
@@ -199,8 +200,7 @@ export default class MarkdownPreview extends React.Component {
? codeBlockTheme ? codeBlockTheme
: 'default' : 'default'
Array.prototype.forEach _.forEach(this.refs.root.contentWindow.document.querySelectorAll('.code code'), (el) => {
.call(this.refs.root.contentWindow.document.querySelectorAll('.code code'), (el) => {
let syntax = CodeMirror.findModeByName(el.className) let syntax = CodeMirror.findModeByName(el.className)
if (syntax == null) syntax = CodeMirror.findModeByName('Plain Text') if (syntax == null) syntax = CodeMirror.findModeByName('Plain Text')
CodeMirror.requireMode(syntax.mode, () => { CodeMirror.requireMode(syntax.mode, () => {
@@ -219,14 +219,13 @@ export default class MarkdownPreview extends React.Component {
opts['element-color'] = '#DDD' opts['element-color'] = '#DDD'
opts['fill'] = '#3A404C' opts['fill'] = '#3A404C'
} }
Array.prototype.forEach _.forEach(this.refs.root.contentWindow.document.querySelectorAll('.flowchart'), (el) => {
.call(this.refs.root.contentWindow.document.querySelectorAll('.flowchart'), (el) => {
Raphael.setWindow(this.getWindow()) Raphael.setWindow(this.getWindow())
try { try {
let diagram = flowchart.parse(decodeHTMLEntities(el.innerHTML)) let diagram = flowchart.parse(decodeHTMLEntities(el.innerHTML))
el.innerHTML = '' el.innerHTML = ''
diagram.drawSVG(el, opts) diagram.drawSVG(el, opts)
Array.prototype.forEach.call(el.querySelectorAll('a'), (el) => { _.forEach(el.querySelectorAll('a'), (el) => {
el.addEventListener('click', this.anchorClickHandler) el.addEventListener('click', this.anchorClickHandler)
}) })
} catch (e) { } catch (e) {