Skip to content

Commit

Permalink
Added comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Jul 17, 2019
1 parent 309f77b commit d6f3a9f
Showing 1 changed file with 44 additions and 11 deletions.
55 changes: 44 additions & 11 deletions lib/mixins/property-effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -2666,28 +2666,61 @@ export const PropertyEffects = dedupingMixin(superClass => {

// -- binding ----------------------------------------------

/*
* Overview of binding flow:
*
* During finalization (`instanceBinding==false`, `wasPreBound==false`):
* `_bindTemplate(false)` called directly during finalization - parses the
* template (for the first time), and then assigns that _prototypical_
* template info to `__preboundTemplateInfo` _on the prototype_; note in
* this case `wasPreBound` is false; this is the first time we're binding
* it, thus we create accessors.
*
* During first stamping (`instanceBinding==true`, `wasPreBound==true`):
* `_stampTemplate` calls `_bindTemplate(true)`: the `templateInfo`
* returned matches the prebound one, and so this is `wasPreBound == true`
* state; thus we _skip_ creating accessors, but _do_ create a
* sub-instance of the template info to serve as the start of our linked
* list (needs to be an instance, not the prototypical one, so that we can
* add `nodeList` to it to contain the `nodeInfo`-ordered list of instance
* nodes for bindings, and so we can chain runtime-stamped template infos
* off of it). At this point, the call to `_stampTemplate` calls
* `applyTemplateInfo` for each nested `<template>` found during parsing
* to hand prototypical `_templateInfo` to them; we also pass the _parent_
* `templateInfo` to the `<template>` so that we have the instance-time
* parent to link the `templateInfo` under in the case it was
* runtime-stamped.
*
* During subsequent runtime stamping (`instanceBinding==true`,
* `wasPreBound==false`): `_stampTemplate` calls `_bindTemplate(true)` -
* here `templateInfo` is guaranteed to _not_ match the prebound one,
* because it was either a different template altogether, or even if it
* was the same template, the step above created a sub-instance of the
* info; in this case `wasPreBound == false`, so we _do_ create accessors,
* _and_ link a sub-instance into the linked list.
*/

/**
* Equivalent to static `bindTemplate` API but can be called on
* an instance to add effects at runtime. See that method for
* full API docs.
* Equivalent to static `bindTemplate` API but can be called on an instance
* to add effects at runtime. See that method for full API docs.
*
* This method may be called on the prototype (for prototypical template
* binding, to avoid creating accessors every instance) once per prototype,
* and will be called with `runtimeBinding: true` by `_stampTemplate` to
* create and link an instance of the template metadata associated with a
* particular stamping.
*
* @override
* @override
* @param {!HTMLTemplateElement} template Template containing binding
* bindings
* bindings
* @param {boolean=} instanceBinding When false (default), performs
* "prototypical" binding of the template and overwrites any previously
* bound template for the class. When true (as passed from
* `_stampTemplate`), the template info is instanced and linked into
* the list of bound templates.
* "prototypical" binding of the template and overwrites any previously
* bound template for the class. When true (as passed from
* `_stampTemplate`), the template info is instanced and linked into the
* list of bound templates.
* @return {!TemplateInfo} Template metadata object; for `runtimeBinding`,
* this is an instance of the prototypical template info
* @protected
* this is an instance of the prototypical template info
* @protected
* @suppress {missingProperties} go/missingfnprops
*/
_bindTemplate(template, instanceBinding) {
Expand Down

0 comments on commit d6f3a9f

Please sign in to comment.