On Sep 4, 4:40 am, JoJo <[email protected]> wrote:
> ^ great article!
>
> Now I have another question. Here is my new workflow in an attempt to
> execute files in the correct order across all browsers. It works in
> IE8, but not in IE7. In IE7 I get an error saying "object expected"
> on line 2 of main.js. This is not very descriptive; what does it
> mean?
>
> (1) include my global wrapper MYAPP.js:
>
> MYAPP = {class1: null, class2: null}
MYAPP is an instance of the built-in Object object (i.e. a native
object). Because it has not been declared, it doesn't exist until the
code is executed.
> (2) include Class1.js (no instantiation)
> (3) include Class2.js (no instantiation)
> (4) include main.js:
>
> Event.observe(window, 'load', function() {
> MYAPP.class1 = new MYAPP.Class1();
Even if MYAPP exists at this point, the above won't work: the only
native objects that can be used as constructors are function objects.
MYAPP is and native object, it can't be used as a constructor as it
doesn't have an internal [[consruct]] method (functions do).
See ECMA-262 section 11.2.2:
| 11.2.2 The new Operator
|
| The production MemberExpression : new MemberExpression Arguments
| is evaluated as follows:
|
| 1. Evaluate MemberExpression.
| 2. Call GetValue(Result(1)).
| 3. Evaluate Arguments, producing an internal list of argument
| values (11.2.4).
| 4. If Type(Result(2)) is not Object, throw a TypeError exception.
| 5. If Result(2) does not implement the internal [[Construct]]
| method, throw a TypeError exception.
| 6. ...
--
Rob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---