Skip to content

Commit

Permalink
canMakeObserve: strictly allowed types
Browse files Browse the repository at this point in the history
Made objects for canMakeObserve more strict; only allow plain JS objects
or existing instances of can.Observe or derived classes (such as
can.Observe.List, can.Model, etc. )

Allowing other things to be wrapped into can.Observe instances may cause
problems as well, so it is better to white-list and be conservative
about what is and is not allowed.

(For example; even wrapping can.Control, which is part of CanJS itself
throws.)
  • Loading branch information
RJG Otten committed Oct 2, 2012
1 parent af4d59b commit 92c98e7
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions observe/observe.js
Expand Up @@ -6,12 +6,7 @@ steal('can/util','can/construct', function(can, Construct) {
//
// Returns `true` if something is an object with properties of its own.
var canMakeObserve = function( obj ) {
return ( obj
&& !obj.nodeType
&& !can.isWindow( obj )
&& !(obj instanceof can.$ )
&& !(obj instanceof Date)
&& ( "object" === typeof obj ));
return obj && ( can.isPlainObject( obj ) || ( obj instanceof can.Observe ));
},

// Removes all listeners.
Expand Down

0 comments on commit 92c98e7

Please sign in to comment.