Skip to content

Commit

Permalink
Update docs and types
Browse files Browse the repository at this point in the history
  • Loading branch information
TimvdLippe committed Feb 25, 2018
1 parent f53e9e8 commit 211c223
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 2 deletions.
11 changes: 11 additions & 0 deletions externs/closure-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,17 @@ Polymer_ArraySelectorMixin.prototype.select = function(item){};
Polymer_ArraySelectorMixin.prototype.selectIndex = function(idx){};
/**
* @interface
* @extends {Polymer_PropertyEffects}
*/
function Polymer_StrictBindingParser(){}
/**
* @param {string} text Text to parse from attribute or textContent
* @param {Object} templateInfo Current template metadata
* @return {Array.<!BindingPart>}
*/
Polymer_StrictBindingParser._parseBindings = function(text, templateInfo){};
/**
* @interface
* @extends {Polymer_ElementMixin}
*/
function Polymer_DisableUpgradeMixin(){}
Expand Down
19 changes: 17 additions & 2 deletions lib/mixins/strict-binding-parser.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<link rel="import" href="../utils/boot.html">
<link rel="import" href="../utils/path.html">
<link rel="import" href="../utils/mixin.html">
<link rel="import" href="../mixins/property-effects.html">

<script>
(function() {
Expand Down Expand Up @@ -113,13 +114,27 @@
* state machine instead of a regex. As such, this implementation is able to
* handle more cases, with the potential performance hit.
*
* @namespace
* @mixinFunction
* @appliesMixin Polymer.PropertyEffects
* @polymer
* @memberof Polymer
* @summary Mixin that parses binding expressions and generates corresponding metadata.
*/
const StrictBindingParser = Polymer.dedupingMixin((base) => {

return class extends base {
/**
* @constructor
* @extends {base}
* @implements {Polymer_PropertyEffects}
*/
const elementBase = Polymer.PropertyEffects(base);

/**
* @polymer
* @mixinClass
* @implements {Polymer_PropertyEffects}
*/
return class extends elementBase {

/**
* Called to parse text in a template (either attribute values or
Expand Down
67 changes: 67 additions & 0 deletions types/lib/mixins/strict-binding-parser.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* DO NOT EDIT
*
* This file was automatically generated by
* https://github.com/Polymer/gen-typescript-declarations
*
* To modify these typings, edit the source file(s):
* lib/mixins/strict-binding-parser.html
*/

/// <reference path="../utils/boot.d.ts" />
/// <reference path="../utils/path.d.ts" />
/// <reference path="../utils/mixin.d.ts" />
/// <reference path="property-effects.d.ts" />

declare namespace Polymer {


/**
* Mixin that parses binding expressions and generates corresponding metadata.
* The implementation is different than in `property-effects`, as it uses a
* state machine instead of a regex. As such, this implementation is able to
* handle more cases, with the potential performance hit.
*/
function StrictBindingParser<T extends new (...args: any[]) => {}>(base: T): T & StrictBindingParserConstructor & Polymer.PropertyEffectsConstructor & Polymer.TemplateStampConstructor & Polymer.PropertyAccessorsConstructor & Polymer.PropertiesChangedConstructor;

interface StrictBindingParserConstructor {
new(...args: any[]): StrictBindingParser;

/**
* Called to parse text in a template (either attribute values or
* textContent) into binding metadata.
*
* Any overrides of this method should return an array of binding part
* metadata representing one or more bindings found in the provided text
* and any "literal" text in between. Any non-literal parts will be passed
* to `_evaluateBinding` when any dependencies change. The only required
* fields of each "part" in the returned array are as follows:
*
* - `dependencies` - Array containing trigger metadata for each property
* that should trigger the binding to update
* - `literal` - String containing text if the part represents a literal;
* in this case no `dependencies` are needed
*
* Additional metadata for use by `_evaluateBinding` may be provided in
* each part object as needed.
*
* The default implementation handles the following types of bindings
* (one or more may be intermixed with literal strings):
* - Property binding: `[[prop]]`
* - Path binding: `[[object.prop]]`
* - Negated property or path bindings: `[[!prop]]` or `[[!object.prop]]`
* - Two-way property or path bindings (supports negation):
* `{{prop}}`, `{{object.prop}}`, `{{!prop}}` or `{{!object.prop}}`
* - Inline computed method (supports negation):
* `[[compute(a, 'literal', b)]]`, `[[!compute(a, 'literal', b)]]`
*
* @param text Text to parse from attribute or textContent
* @param templateInfo Current template metadata
* @returns Array of binding part metadata
*/
_parseBindings(text: string, templateInfo: object|null): BindingPart[]|null;
}

interface StrictBindingParser {
}
}

0 comments on commit 211c223

Please sign in to comment.