@@ -96,7 +96,7 @@ function completer (text) {
96
96
97
97
// scope variables
98
98
for ( const def in scope ) {
99
- if ( scope . hasOwnProperty ( def ) ) {
99
+ if ( hasOwnProperty ( scope , def ) ) {
100
100
if ( def . indexOf ( keyword ) === 0 ) {
101
101
matches . push ( def )
102
102
}
@@ -113,7 +113,7 @@ function completer (text) {
113
113
// math functions and constants
114
114
const ignore = [ 'expr' , 'type' ]
115
115
for ( const func in math . expression . mathWithTransform ) {
116
- if ( math . expression . mathWithTransform . hasOwnProperty ( func ) ) {
116
+ if ( hasOwnProperty ( math . expression . mathWithTransform , func ) ) {
117
117
if ( func . indexOf ( keyword ) === 0 && ignore . indexOf ( func ) === - 1 ) {
118
118
matches . push ( func )
119
119
}
@@ -122,24 +122,24 @@ function completer (text) {
122
122
123
123
// units
124
124
const Unit = math . Unit
125
- for ( let name in Unit . UNITS ) {
126
- if ( Unit . UNITS . hasOwnProperty ( name ) ) {
125
+ for ( const name in Unit . UNITS ) {
126
+ if ( hasOwnProperty ( Unit . UNITS , name ) ) {
127
127
if ( name . indexOf ( keyword ) === 0 ) {
128
128
matches . push ( name )
129
129
}
130
130
}
131
131
}
132
- for ( let name in Unit . PREFIXES ) {
133
- if ( Unit . PREFIXES . hasOwnProperty ( name ) ) {
132
+ for ( const name in Unit . PREFIXES ) {
133
+ if ( hasOwnProperty ( Unit . PREFIXES , name ) ) {
134
134
const prefixes = Unit . PREFIXES [ name ]
135
135
for ( const prefix in prefixes ) {
136
- if ( prefixes . hasOwnProperty ( prefix ) ) {
136
+ if ( hasOwnProperty ( prefixes , prefix ) ) {
137
137
if ( prefix . indexOf ( keyword ) === 0 ) {
138
138
matches . push ( prefix )
139
139
} else if ( keyword . indexOf ( prefix ) === 0 ) {
140
140
const unitKeyword = keyword . substring ( prefix . length )
141
141
for ( const n in Unit . UNITS ) {
142
- if ( Unit . UNITS . hasOwnProperty ( n ) ) {
142
+ if ( hasOwnProperty ( Unit . UNITS , n ) ) {
143
143
if ( n . indexOf ( unitKeyword ) === 0 &&
144
144
Unit . isValuelessUnit ( prefix + n ) ) {
145
145
matches . push ( prefix + n )
@@ -424,3 +424,9 @@ if (version) {
424
424
}
425
425
} )
426
426
}
427
+
428
+ // helper function to safely check whether an object as a property
429
+ // copy from the function in object.js which is ES6
430
+ function hasOwnProperty ( object , property ) {
431
+ return object && Object . hasOwnProperty . call ( object , property )
432
+ }
0 commit comments