Skip to content

Commit 12d94e1

Browse files
committed
Document ol.inherits and annotate as a function
1 parent 10aa201 commit 12d94e1

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

src/ol/ol.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,34 @@ ol.ZOOMSLIDER_ANIMATION_DURATION = 200;
208208

209209

210210
/**
211-
* ol.inherits is an alias to the goog.inherits function. It is exported
212-
* for use in non-compiled application code.
211+
* Inherit the prototype methods from one constructor into another.
213212
*
214-
* FIXME: We use a new line to fake the linter. Without the new line the
215-
* linter complains with:
213+
* Usage:
216214
*
217-
* "Missing newline between constructor and goog.inherits"
215+
* function ParentClass(a, b) { }
216+
* ParentClass.prototype.foo = function(a) { }
217+
*
218+
* function ChildClass(a, b, c) {
219+
* goog.base(this, a, b);
220+
* }
221+
* ol.inherits(ChildClass, ParentClass);
222+
*
223+
* var child = new ChildClass('a', 'b', 'see');
224+
* child.foo(); // This works.
225+
*
226+
* In addition, a superclass' implementation of a method can be invoked as
227+
* follows:
228+
*
229+
* ChildClass.prototype.foo = function(a) {
230+
* ChildClass.superClass_.foo.call(this, a);
231+
* // Other code here.
232+
* };
233+
*
234+
* @param {Function} childCtor Child constructor.
235+
* @param {Function} parentCtor Parent constructor.
236+
* @function
218237
* @api
219238
*/
220239
ol.inherits =
221240
goog.inherits;
241+
// note that the newline above is necessary to satisfy the linter

0 commit comments

Comments
 (0)