@@ -129,6 +129,11 @@ declare namespace Polymer {
129129 * from `instance.parentModel` in cases where template instance nesting
130130 * causes an inner model to shadow an outer model.
131131 *
132+ * All callbacks are called bound to the `owner`. Any context
133+ * needed for the callbacks (such as references to `instances` stamped)
134+ * should be stored on the `owner` such that they can be retrieved via
135+ * `this`.
136+ *
132137 * When `options.forwardHostProp` is declared as an option, any properties
133138 * referenced in the template will be automatically forwarded from the host of
134139 * the `<template>` to instances, with the exception of any properties listed in
@@ -138,14 +143,18 @@ declare namespace Polymer {
138143 * always be set to the instance (regardless of whether they would normally
139144 * be forwarded from the host).
140145 *
141- * Note that the class returned from `templatize` is generated only once
142- * for a given `<template>` using `options` from the first call for that
143- * template, and the cached class is returned for all subsequent calls to
144- * `templatize` for that template. As such, `options` callbacks should not
145- * close over owner-specific properties since only the first `options` is
146- * used; rather, callbacks are called bound to the `owner`, and so context
147- * needed from the callbacks (such as references to `instances` stamped)
148- * should be stored on the `owner` such that they can be retrieved via `this`.
146+ * Note that `templatize()` can be run only once for a given `<template>`.
147+ * Further calls will result in an error. Also, there is a special
148+ * behavior if the template was duplicated through a mechanism such as
149+ * `<dom-repeat>` or `<test-fixture>`. In this case, all calls to
150+ * `templatize()` return the same class for all duplicates of a template.
151+ * The class returned from `templatize()` is generated only once using
152+ * the `options` from the first call. This means that any `options`
153+ * provided to subsequent calls will be ignored. Therefore, it is very
154+ * important not to close over any variables inside the callbacks. Also,
155+ * arrow functions must be avoided because they bind the outer `this`.
156+ * Inside the callbacks, any contextual information can be accessed
157+ * through `this`, which points to the `owner`.
149158 *
150159 * @returns Generated class bound to the template
151160 * provided
0 commit comments