clientside / amplesdk

Ample SDK - JavaScript UI Framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ample.extend: Order of arguments changed, documentation not updated

amoilanen opened this issue · comments

The order of arguments in ample.extend changed compared with the commit 4063ca1 from Oct 14 2012 and this is not reflected in the documentation. The following test fails because of the wrong order of the arguments:

(function() {

    test("Query.extend: parent functions are inherited", function () {
        function Class1(field1) {
            this.field1 = field1;
        };

        Class1.prototype.method1 = function () {
            return this.field1;
        };

        function Class2(field1) {
            Class1.call(this, field1);
        };

        ample.extend(Class2.prototype, Class1.prototype);

        var obj1 = new Class1("Class1.Object1");
        var obj2 = new Class2("Class2.Object1");

        equal(obj1.method1 ? obj1.method1() : "", "Class1.Object1");

        //Fails: obj2.method1 is "undefined"
        equal(obj2.method1 ? obj2.method1() : "", "Class2.Object1");
    });
})();

In documentation:

Syntax:

object.extend(target, source)
Arguments:

Name Type O/R Description
target Object Required Target object for extension.
source Object Required Source object to extend from.

When we change the order of arguments

ample.extend(Class1.prototype, Class2.prototype);

the test passes.

Regression fixed per rev bd30e13. The order of arguments was not supposed to be changed (only documentation) compared to earlier behavior.