Skip to content

Commit 35e8a25

Browse files
committed
fix: use hasOwnProperty instead of []
`keywordsBlockAndTransactionProperties[cur].some` is not a function error. If current token (`cur`) is a method from Object like `toString`, `keywordsBlockAndTransactionProperties[cur]` is keywordsBlockAndTransactionProperties['toString'] and would be a function, then `fn.some` would throw the error.
1 parent bf1531a commit 35e8a25

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mode/solidity/solidity.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,17 +339,17 @@ CodeMirror.defineMode('solidity', function(config) {
339339

340340
if (
341341
keywordsMoreBlockAndTransactionProperties.propertyIsEnumerable(cur) ||
342-
(keywordsBlockAndTransactionProperties[cur] &&
343-
keywordsBlockAndTransactionProperties[cur].some(function(item) {
342+
(keywordsBlockAndTransactionProperties.hasOwnProperty(cur) &&
343+
keywordsBlockAndTransactionProperties[cur].some(function (item) {
344344
return stream.match('.' + item)
345345
}))
346346
) {
347347
return 'variable-2'
348348
}
349349

350350
if (
351-
keywordsAbiEncodeDecodeFunctions[cur] &&
352-
keywordsAbiEncodeDecodeFunctions[cur].some(function(item) {
351+
keywordsAbiEncodeDecodeFunctions.hasOwnProperty(cur) &&
352+
keywordsAbiEncodeDecodeFunctions[cur].some(function (item) {
353353
return stream.match('.' + item)
354354
})
355355
) {

0 commit comments

Comments
 (0)