V8 runtime defines Object.prototype.extend which may break compatibility to javascript framework

You must Login before you can answer or comment on any questions.

We are using the stripped down version of the qooxdoo javascript framework ( called qx-oo ( ). This is well crafted OO-part with inheritence, mixins, events and so forth.

The qooxdoo class definition mechanism checks the existence of an attribute called "extend" within the class definition arguments which are defined as an object with attributes.

qooxdoo decides on the absence or existence of the attribute "extend" if a class has only statics or if the class is used for instantiation.

Because of the defined "extend" attribute/function/method in Object.prototype.extend this mechanism breaks.

The attempt to remove Object.prototype.extend via delete is ignored.

Tests with standalone V8 on centos 6 showed that Object.prototype.extend is not defined there. So it is unique to the titanium android V8 derivate.

What is Object.prototype.extend used for? How can I remove it?

On iOS qooxdoo is usable without any problems.

See also:

4 Answers

Accepted Answer

Hey guys, Thanks for bringing this to my attention :)

We indeed added Object.prototype.extend, and use it for object merging/mixins. You can find the code for this in github

In retrospect, I agree with the general sentiment here -- we should move Object.prototype.extend to an internal namespace, so I've opened TIMOB-6684 to track the fix.

— answered 4 years ago by Marshall Culpepper
answer permalink
  • @Marshall: thank you for the fast reaction on this issue.

    Do you have any timeframe for the fix? Will it be in 1.8 GA?

    Any chance to fix this via a patch in the current SDK continuous builds?

    — commented 4 years ago by Dietrich Streifert

  • @Dietrich: You're welcome!

    I'm currently targeting this fix for 1.8.1, since our 1.8 GA stream is frozen except for high priority fixes at this point.

    Renaming the function is relatively trivial, but we want to make sure all the places that use it internally are correctly updated / tested as well :)

    — commented 4 years ago by Marshall Culpepper

  • @Marshall: Any sceduled date when the fix will be available in the continuous builds?

    Maybe in master?

    I'll need a fix asap because I'm currently "porting" an iOS app to android which is based on the qx-oo framework which relies on the absence of the extend property.

    — commented 4 years ago by Dietrich Streifert

  • Show 7 more comments

IMHO, extending "Object.prototype" (or any native prototype) is a bad practice in general. No matter that, in Titanium v8 implementation, function "extend" in "Object.prototype" should be considered as a bug since it's not defined in ECMAScript specification.

— answered 4 years ago by Ivan Škugor
answer permalink
  • Yes this should be avoided, but i.e. prototype is doing it:

    — commented 4 years ago by Dietrich Streifert

  • If there are people that use that approach, it doesn't mean it's a good thing in general.

    There are plenty topics on the internet about why extending native prototypes is not good practice, you can try to find them if you don't believe this side effect that you're experiencing now. :)

    — commented 4 years ago by Ivan Škugor

  • After doing a

    The following code is unveiled:
    function (other) {
       if (!other) return;
       for (var name in other) {
          if (other.hasOwnProperty(name)) {
             this[name] = other[name];
       return this;
    This is obviously code to merge the properties/attributes of a given object to the current instance.

    I've tried to identify this code within the sdk but had no luck.

    Does this code ring the bells for anyone?

    — commented 4 years ago by Dietrich Streifert

  • Show 1 more comment

It isnt possible to prototype Ti-objects.

— answered 4 years ago by Rainer Schleevoigt
answer permalink
  • Maybe, but if it is just used internally it should be named accordingly with something which is not potentially colliding. Somthing like __Ti.extend. And it should be documented to be aware of it.

    — commented 4 years ago by Dietrich Streifert

  • He's not talking about Titanium objects. "extend" is added to native object, try to run this:

    Ti.API.debug(typeof Object.prototype.extend);
    Should get "function" on v8, while on Rhino you'll get "undefined" as it should be.

    — commented 4 years ago by Ivan Škugor

Your Answer

Think you can help? Login to answer this question!