Unimplemented Features Error #1

Closed
jangaroo opened this Issue Mar 21, 2010 · 4 comments

Projects

None yet

2 participants

@jangaroo

Currently, if any of the unimplemented features "writable", "enumerable" or "configurable" is set to true, an error is thrown.

// can't implement these features so throw a RangeError if any are true
if (descriptor.writable || descriptor.enumerable || descriptor.configurable) {
  throw new RangeError("This implementation of Object.defineProperty does not support configurable, enumerable, or writable.");
}

Since all user-defined properties in ECMAScript 3 are in fact writable, enumerable, and configurable, I think it makes more sense to throw an error if any configuration attribute is explicitly set to false:

// can't switch off these features in ECMAScript 3 so throw a RangeError if any are false
if (descriptor.writable===false || descriptor.enumerable===false || descriptor.configurable===false) {
  throw new RangeError("This implementation of Object.defineProperty does not support to switch off configurable, enumerable, or writable.");
}
@eligrey
Owner

Ah, yeah I should have done that instead. Also, technically, enumerable can be implemented with __iterator__ hacks and I may make a separate library for that.

@jangaroo

Didn't know about iterator! Which browsers / JS engines support that? (Firefox hit: https://developer-stage.mozilla.org/en/Core_JavaScript_1.5_Guide/Iterators_and_Generators)
Btw., I added some background information to the project Wiki homepage.

@eligrey
Owner

Thanks for the background info. All official JavaScript engines by Mozilla support iterators and generators. I've never used ActionScript, but I think it may also implement it as there was stuff about iterators and generators in ECMAScript 4.

@eligrey
Owner
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment