Index: trunk/parsers/wikidom/lib/es/es.js |
— | — | @@ -5,8 +5,10 @@ |
6 | 6 | */ |
7 | 7 | var es = {}; |
8 | 8 | |
| 9 | +/* Functions */ |
| 10 | + |
9 | 11 | /** |
10 | | - * Extends a constructor with prototype of another. |
| 12 | + * Extends a constructor with the prototype of another. |
11 | 13 | * |
12 | 14 | * When using this, it's required to include a call to the constructor of the parent class as the |
13 | 15 | * first code in the child class's constructor. |
— | — | @@ -14,6 +16,7 @@ |
15 | 17 | * @example |
16 | 18 | * // Define parent class |
17 | 19 | * function Foo() { |
| 20 | + * // code here |
18 | 21 | * } |
19 | 22 | * // Define child class |
20 | 23 | * function Bar() { |
— | — | @@ -23,16 +26,14 @@ |
24 | 27 | * // Extend prototype |
25 | 28 | * extend( Bar, Foo ); |
26 | 29 | * |
27 | | - * @param dst {Function} Class to copy prototype members to |
28 | | - * @param src {Function} Class to copy prototype members from |
| 30 | + * @param dst {Function} Class to extend |
| 31 | + * @param src {Function} Base class to use methods from |
29 | 32 | */ |
30 | 33 | es.extend = function( dst, src ) { |
31 | 34 | var base = new src(); |
32 | | - var i; // iterator |
33 | | - |
34 | | - for ( i in base ) { |
35 | | - if ( typeof base[i] === 'function' && !( i in dst.prototype ) ) { |
36 | | - dst.prototype[i] = base[i]; |
| 35 | + for ( var method in base ) { |
| 36 | + if ( typeof base[method] === 'function' && !( method in dst.prototype ) ) { |
| 37 | + dst.prototype[method] = base[method]; |
37 | 38 | } |
38 | 39 | } |
39 | 40 | } |