mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Fix Gestures when using SD polyfill
Test with SD polyfill and native ShadowDOM Requires webcomponents/webcomponentsjs#434 Fixes #2641
This commit is contained in:
parent
0dc69dfbe5
commit
96e4bfa5b1
@ -199,8 +199,11 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
handleNative: function(ev) {
|
||||
var handled;
|
||||
var type = ev.type;
|
||||
var node = ev.currentTarget;
|
||||
var node = wrap(ev.currentTarget);
|
||||
var gobj = node[GESTURE_KEY];
|
||||
if (!gobj) {
|
||||
return;
|
||||
}
|
||||
var gs = gobj[type];
|
||||
if (!gs) {
|
||||
return;
|
||||
@ -292,6 +295,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
|
||||
// automate the event listeners for the native events
|
||||
add: function(node, evType, handler) {
|
||||
// SD polyfill: handle case where `node` is unwrapped, like `document`
|
||||
node = wrap(node);
|
||||
var recognizer = this.gestures[evType];
|
||||
var deps = recognizer.deps;
|
||||
var name = recognizer.name;
|
||||
@ -323,6 +328,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
|
||||
// automate event listener removal for native events
|
||||
remove: function(node, evType, handler) {
|
||||
// SD polyfill: handle case where `node` is unwrapped, like `document`
|
||||
node = wrap(node);
|
||||
var recognizer = this.gestures[evType];
|
||||
var deps = recognizer.deps;
|
||||
var name = recognizer.name;
|
||||
|
@ -41,6 +41,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
'unit/array-selector.html',
|
||||
'unit/events.html',
|
||||
'unit/gestures.html',
|
||||
'unit/gestures.html?dom=shadow',
|
||||
'unit/utils.html',
|
||||
'unit/utils-content.html',
|
||||
'unit/utils.html?dom=shadow',
|
||||
|
@ -139,3 +139,28 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
});
|
||||
</script>
|
||||
</dom-module>
|
||||
|
||||
<dom-module id="x-document-listener">
|
||||
<script>
|
||||
Polymer({
|
||||
is: 'x-document-listener',
|
||||
properties: {
|
||||
stream: {
|
||||
type: Array,
|
||||
value: function() {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
},
|
||||
setup: function() {
|
||||
this.listen(document, 'down', 'handler');
|
||||
},
|
||||
teardown: function() {
|
||||
this.unlisten(document, 'down', 'handler');
|
||||
},
|
||||
handler: function(e) {
|
||||
this.stream.push(e);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</dom-module>
|
||||
|
@ -12,7 +12,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<script src="../../../webcomponentsjs/webcomponents.js"></script>
|
||||
<script src="../../../web-component-tester/browser.js"></script>
|
||||
|
||||
<link rel="import" href="../../polymer.html">
|
||||
@ -386,6 +386,26 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('SD Polyfill', function() {
|
||||
var el;
|
||||
setup(function() {
|
||||
el = document.createElement('x-document-listener');
|
||||
document.body.appendChild(el);
|
||||
el.setup();
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
el.teardown();
|
||||
document.body.removeChild(el);
|
||||
});
|
||||
|
||||
test('document listener works in SD polyfill', function() {
|
||||
var ev = new CustomEvent('mousedown', {bubbles: true});
|
||||
el.dispatchEvent(ev);
|
||||
assert.equal(el.stream.length, 1);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user