Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix define empty descriptor #315

Merged
merged 1 commit into from
Jun 24, 2015
Merged

fix define empty descriptor #315

merged 1 commit into from
Jun 24, 2015

Conversation

yiminghe
Copy link
Contributor

It should not throw error for empty descriptor

Object.defineProperty({},'a',{});

It is used in intl: https://github.com/andyearnshaw/Intl.js/blob/1fced3d60d004b9a853e3699cc6f3329096957da/src/core.js#L119

@ljharb
Copy link
Member

ljharb commented Jun 24, 2015

This relates to #297, specifically #297 (comment)

In addition,

Object.defineProperty(object, 'sentinel', {});
would need to change as well, preferably setting "value".

I think your change is good, but the question remains, what should happen if the descriptor is not empty? ie, if value is not provided, get and set are not provided, but configurable, enumerable, and writable are present? It seems to me like it should throw, whereas with your change, it would silently fail.

@yiminghe
Copy link
Contributor Author

Get and set must throw, because old ie does not support it and the rest of code will fall definitely.

But others does not need to throw, warning is enough.

If you do not want to change, then I have to ask intl ...

@ljharb
Copy link
Member

ljharb commented Jun 24, 2015

OK so since https://github.com/yiminghe/es5-shim/blob/definePropertyFix/es5-sham.js#L383-L395 is the current behavior of the "value" path, it should be the same behavior for the "non-value" path.

If ever those lines become uncommented, they'd be moved up and run in both code paths. So your change shouldn't affect that.

ljharb added a commit that referenced this pull request Jun 24, 2015
Shimmed `Object.defineProperty` should not throw for an empty descriptor
@ljharb ljharb merged commit 0b903e9 into es-shims:master Jun 24, 2015
@schmod
Copy link

schmod commented Jun 24, 2015

Thanks for taking the time to fix this. This is clearly an improvement over the current status quo :)

@ljharb
Copy link
Member

ljharb commented Jun 24, 2015

I'll release this over the next couple days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants