service2.js: Unify equal/same comparisons
This commit is contained in:
parent
5f83dfa4ba
commit
0e7e324694
12
service2.js
12
service2.js
@ -382,7 +382,7 @@ class BesDOMService extends BesService {
|
|||||||
// Block elements are grammar-checked independently.
|
// Block elements are grammar-checked independently.
|
||||||
this.onProofing()
|
this.onProofing()
|
||||||
let result = this.getProofing(node)
|
let result = this.getProofing(node)
|
||||||
if (result != null) {
|
if (result) {
|
||||||
this.onProofingProgress(result.matches.length)
|
this.onProofingProgress(result.matches.length)
|
||||||
return [{ text: `<${node.tagName}/>`, node: node, markup: true }]
|
return [{ text: `<${node.tagName}/>`, node: node, markup: true }]
|
||||||
}
|
}
|
||||||
@ -663,14 +663,14 @@ class BesDOMService extends BesService {
|
|||||||
// Walk parent nodes from start to common ancestor.
|
// Walk parent nodes from start to common ancestor.
|
||||||
for (node = start.parentNode; node; node = node.parentNode) {
|
for (node = start.parentNode; node; node = node.parentNode) {
|
||||||
nodes.push(node)
|
nodes.push(node)
|
||||||
if (node == commonAncestor) break
|
if (node === commonAncestor) break
|
||||||
}
|
}
|
||||||
nodes.reverse()
|
nodes.reverse()
|
||||||
|
|
||||||
// Walk children and siblings from start until end node is found.
|
// Walk children and siblings from start until end node is found.
|
||||||
for (node = start; node; node = BesDOMService.getNextNode(node)) {
|
for (node = start; node; node = BesDOMService.getNextNode(node)) {
|
||||||
nodes.push(node)
|
nodes.push(node)
|
||||||
if (node == end) break
|
if (node === end) break
|
||||||
}
|
}
|
||||||
|
|
||||||
return nodes
|
return nodes
|
||||||
@ -904,7 +904,7 @@ class BesPlainTextService extends BesService {
|
|||||||
) {
|
) {
|
||||||
this.reEOP.lastIndex = start
|
this.reEOP.lastIndex = start
|
||||||
let match = this.reEOP.exec(text)
|
let match = this.reEOP.exec(text)
|
||||||
if (match !== null) {
|
if (match) {
|
||||||
eop = match.index
|
eop = match.index
|
||||||
end = this.reEOP.lastIndex
|
end = this.reEOP.lastIndex
|
||||||
} else {
|
} else {
|
||||||
@ -924,7 +924,7 @@ class BesPlainTextService extends BesService {
|
|||||||
|
|
||||||
this.onProofing()
|
this.onProofing()
|
||||||
let result = this.getProofing(paragraphRange)
|
let result = this.getProofing(paragraphRange)
|
||||||
if (result != null) {
|
if (result) {
|
||||||
this.onProofingProgress(result.matches.length)
|
this.onProofingProgress(result.matches.length)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -1550,7 +1550,7 @@ window.addEventListener('load', () => {
|
|||||||
if (hostElement.tagName === 'TEXTAREA') {
|
if (hostElement.tagName === 'TEXTAREA') {
|
||||||
BesTAService.register(hostElement)
|
BesTAService.register(hostElement)
|
||||||
} else if (
|
} else if (
|
||||||
hostElement.getAttribute('contenteditable').toLowerCase() ==
|
hostElement.getAttribute('contenteditable').toLowerCase() ===
|
||||||
'plaintext-only'
|
'plaintext-only'
|
||||||
) {
|
) {
|
||||||
BesPlainTextService.register(hostElement)
|
BesPlainTextService.register(hostElement)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user