Skip to content

Commit

Permalink
Add GestureEventListeners to dom-bind.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Apr 13, 2017
1 parent afa843c commit 4f628fd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
6 changes: 5 additions & 1 deletion lib/elements/dom-bind.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@
<link rel="import" href="../utils/boot.html">
<link rel="import" href="../mixins/property-effects.html">
<link rel="import" href="../mixins/mutable-data.html">
<link rel="import" href="../mixins/gesture-event-listeners.html">

<script>

(function() {
'use strict';

const domBindBase = Polymer.OptionalMutableData(Polymer.PropertyEffects(HTMLElement));
const domBindBase =
Polymer.GestureEventListeners(
Polymer.OptionalMutableData(
Polymer.PropertyEffects(HTMLElement)));

/**
* Custom element to allow using Polymer's template features (data binding,
Expand Down
29 changes: 18 additions & 11 deletions test/unit/dom-bind.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<dom-bind id="declarativeDomBind">
<template>
<x-basic id="declaredXBasic1" value="{{value}}" notifyingvalue="{{nvalue}}" on-custom="handleEvent" computed="{{compute(dep)}}"></x-basic>
<x-basic id="declaredXBasic1" value="{{value}}" notifyingvalue="{{nvalue}}" on-custom="handleEvent" on-tap="handleTap" computed="{{compute(dep)}}"></x-basic>
<x-basic id="declaredXBasic2" value="{{value}}" notifyingvalue="{{nvalue}}"></x-basic>
<x-produce-a bind-to-text={{boundText}}></x-produce-a>
<div id="boundTextDiv">{{boundText}}</div>
Expand Down Expand Up @@ -89,12 +89,9 @@
});

test('event listener fires', function() {
var count = 0;
domBind.handleEvent = function() {
count++;
};
domBind.handleEvent = sinon.spy();
el1.fire('custom');
assert.equal(count, 1);
assert.equal(domBind.handleEvent.callCount, 1);
});

test('inline function runs', function() {
Expand Down Expand Up @@ -130,6 +127,7 @@
el1.setAttribute('value', '{{value}}');
el1.setAttribute('notifyingvalue', '{{nvalue}}');
el1.setAttribute('on-custom', 'handleEvent');
el1.setAttribute('on-tap', 'handleTap');
el1.setAttribute('computed', '{{compute(dep)}}');

el2 = doc.createElement('x-basic');
Expand Down Expand Up @@ -165,12 +163,21 @@
});

test('event listener fires', function() {
var count = 0;
domBind.handleEvent = function() {
count++;
};
domBind.handleEvent = sinon.spy();
el1.fire('custom');
assert.equal(count, 1);
assert.equal(domBind.handleEvent.callCount, 1);
});

test('gesture event listener fires', function() {
domBind.handleTap = sinon.spy();
el1.click();
assert.equal(domBind.handleTap.callCount, 1);
});

test('gesture event listener fires', function() {
domBind.handleTap = sinon.spy();
el1.click();
assert.equal(domBind.handleTap.callCount, 1);
});

test('inline function runs', function() {
Expand Down

0 comments on commit 4f628fd

Please sign in to comment.