This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ function filterFilter() {
125125 case 'object' :
126126 // Replace `{$: 'xyz'}` with `'xyz'` and fall through
127127 var keys = Object . keys ( expression ) ;
128- if ( ( keys . length === 1 ) && ( keys [ 0 ] === '$' ) ) expression = expression . $ ;
128+ if ( ( keys . length === 1 ) && ( keys [ 0 ] === '$' ) ) expression = expression . $ ;
129129 // jshint -W086
130130 case 'boolean' :
131131 case 'number' :
Original file line number Diff line number Diff line change @@ -156,6 +156,26 @@ describe('Filter: filter', function() {
156156 } ) ;
157157
158158
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+
159179 describe ( 'should support comparator' , function ( ) {
160180
161181 it ( 'as equality when true' , function ( ) {
You can’t perform that action at this time.
0 commit comments