File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ function filterFilter() {
125
125
case 'object' :
126
126
// Replace `{$: 'xyz'}` with `'xyz'` and fall through
127
127
var keys = Object . keys ( expression ) ;
128
- if ( ( keys . length === 1 ) && ( keys [ 0 ] === '$' ) ) expression = expression . $ ;
128
+ if ( ( keys . length === 1 ) && ( keys [ 0 ] === '$' ) ) expression = expression . $ ;
129
129
// jshint -W086
130
130
case 'boolean' :
131
131
case 'number' :
Original file line number Diff line number Diff line change @@ -156,6 +156,26 @@ describe('Filter: filter', function() {
156
156
} ) ;
157
157
158
158
159
+ it ( 'should not consider the expression\'s inherited properties' , function ( ) {
160
+ Object . prototype . noop = noop ;
161
+
162
+ var items = [
163
+ { text : 'hello' } ,
164
+ { text : 'goodbye' } ,
165
+ { text : 'kittens' } ,
166
+ { text : 'puppies' }
167
+ ] ;
168
+
169
+ expect ( filter ( items , { text : 'hell' } ) . length ) . toBe ( 1 ) ;
170
+ expect ( filter ( items , { text : 'hell' } ) [ 0 ] ) . toBe ( items [ 0 ] ) ;
171
+
172
+ expect ( filter ( items , 'hell' ) . length ) . toBe ( 1 ) ;
173
+ expect ( filter ( items , 'hell' ) [ 0 ] ) . toBe ( items [ 0 ] ) ;
174
+
175
+ delete ( Object . prototype . noop ) ;
176
+ } ) ;
177
+
178
+
159
179
describe ( 'should support comparator' , function ( ) {
160
180
161
181
it ( 'as equality when true' , function ( ) {
You can’t perform that action at this time.
0 commit comments