Opened 15 years ago

Closed 15 years ago

Last modified 12 years ago

#1581 closed enhancement (invalid)

isSet(property) reflection method

Reported by: [email protected] Owned by: tk
Priority: high Milestone: 0.9
Component: General Version: 0.3
Keywords: Cc: [email protected]…, [email protected]
Blocked By: Blocking:


Could we put a


method in dojo.lang


that works like this:

function isSet(property) {

if (property == ) {

return false;



Change History (9)

comment:1 Changed 15 years ago by dylan

Milestone: 0.5
Owner: changed from anonymous to tk

comment:2 Changed 15 years ago by guest


It's supposed to be

if (property == ) { return false}

comment:3 Changed 15 years ago by tk

Cc: [email protected] [email protected] added
Status: newassigned

What are you checking for the property of?

If an object.... check dojo.lang.has(object, "property"); Otherwise... are you asking for a way to test variables set/null/undefined?

comment:4 Changed 15 years ago by [email protected]

this kind of function can not be created with javascript.


Because myFunction(property) will not work if property is not defined.

So what will work then?

  if (typeof(property) == "undefined") { ... }

comment:5 Changed 15 years ago by [email protected]


Good point.

The property does need to be defined.

I'm using isSet() within the dojo.presentation framework as a way to communicate whether a property has been set or not.

So a component has properties that are declared using dojo.declare().

The definition within the dojo.presentation of an unset property is


So we could add:

if ( typeof( property == 'undefined' ) { throw new Error("The property must be created before the isSet method can be used.") }

I think a isDefined() or exists() method should be substituted for

property == 'undefined'

so function isDefined(property) {

if (property == 'undefined') return false;


So to summarize: isSet assumes the property exists and that the unset value is .

isDefined / exists() checks whether the property exists to start with.


comment:6 Changed 15 years ago by [email protected]

Incidentally - I'm aiming for a reflective method similar to the one used in the Eclipse EMF API on the EObject:

Here's the API Description:

(EStructuralFeature in Javascript would be either an Object reference or a primitive like String)


public boolean eIsSet(EStructuralFeature feature)

Returns whether the feature of the object is considered to be set.

If the feature is many-valued, the value must be an EList and the feature is considered set if the list is not empty. If the feature is unsettable, the modeled state is directly available and is used. Otherwise, the unresolved value of the feature of the object is compared against the feature's default value or the meta class's default value, as appropriate; the feature is considered set if it's not the same as the default.

This property can affect serialization, since defaults are typically omitted in a compact serialization.


feature - the feature in question.


whether the feature of the object is set.


IllegalArgumentException? - if the feature is not one the meta class's features.

See Also:

eSet(EStructuralFeature, Object), eUnset(EStructuralFeature), eGet(EStructuralFeature, boolean)

Slightly OT:

Since one of the goals of dojo.presentation is also to handle dojo.presentation.application.Application client side persistence, I'll be using the EMF API as a baseline for some of the reflective features used in the dojo.presentation API.

Right now isSet lives in dojo.presentation.reflection.

So if we agree on what isSet, etc. means hopefully the methods can find a home a home in dojo.lang...

comment:7 Changed 15 years ago by tk

You description sounds conveniently similiar to dojo.lang.has(obj,prop)....

comment:8 Changed 15 years ago by [email protected]

Hmmm - I just looked at it:

dojo.lang.has = function(obj, name){


return (typeof obj[name] != "undefined");

}catch(e){ return false; }


So I get true if it's not 'undefined'

I want true if it's not "".

I think that's an important difference.

I also noticed that there is a isUndefined method...

which would satisfy the exists() part discussed.

So when I use isSet(property) I know that the property exists already/should exist. I just want to know whether someone configured it, or whether it is set to the "UN_SET" value.

If I use dojo.lang.has(), it should always return true.

comment:9 Changed 15 years ago by tk

Resolution: invalid
Status: assignedclosed

Recommended to close this, so doing so.

Note: See TracTickets for help on using tickets.