Re: Setting property attributes after calling JS_SetProperty()
Tom Schuster <[email protected]> Wed, 1 Jul 2020 22:22:38 +0200
| Newsgroups | gmane.comp.mozilla.devel.jseng |
|---|---|
| Message-ID | <CAN7ST61VpinVgc1pwvo21S1e2fZ=aD9p66upbKimFzs=C6ZyuQ@mail.gmail.com> |
Hi!
You can instead use JS_DefineProperty to directly set the property
attributes while defining a new property.
Example:
if (!JS_DefineProperty(cx, object, "name", value, JSPROP_PERMANENT)) {
return false;
}
Cheers,
Tom
On Wed, Jul 1, 2020 at 6:00 PM <[email protected]> wrote:
>
> Hi,
>
>
> I'm currently trying to upgrade a program from using JS 1.8.5 to JS 76. In doing this, I've come across a function in which we try to:
>
> - set a property that doesn't initially exist on an object, using JS_SetProperty(),
>
> - then set that property's attributes to be JSPROP_PERMANENT, using JS_SetPropertyAttributes().
>
> However, in JS 76, JS_SetPropertyAttributes() doesn't appear to exist. Instead, I've had to:
>
> - get the property descriptor, using JS_GetPropertyDescriptor(),
>
> - then set the attributes using .setAttributes().
>
> I'm struggling to find any documentation on the matter so I'm not sure if this is even correct. Is there a new/alternative function to replace JS_SetPropertyAttributes() with?
>
>
> Many thanks,
> Harry
> _______________________________________________
> dev-tech-js-engine mailing list
> [email protected]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine