Description
In Qt 4, default-constructed QScriptValues are invalid (QScriptValue::isValid() returns false).
Invalid values are used as a form of error reporting:
QScriptValue::call() returns an invalid value if invoked on a non-callable.
QScriptValue::property() returns an invalid value if the property doesn't exist.
Additionally, an invalid value can be used to delete a property, by calling QScriptValue::setProperty() with an invalid value as argument.
JavaScript has no concept of invalid values. When an invalid value is returned back to JS (for example, as the result of a native function call), the value is implicitly converted to undefined.
It would be nice to get rid of the whole concept of invalid values, and have them become undefined values instead.
Some additional API must be introduced to enable this, such as QScriptValue::hasOwnProperty() to determine if a property exists, and QScriptValue::deleteProperty() to enable property deletion.
Attachments
Issue Links
- relates to
-
QTBUG-16504 Add QScriptValue::deleteProperty()
-
- Closed
-