Skip to content

Commit

Permalink
Ensure dispatchEvent is wrapped
Browse files Browse the repository at this point in the history
When `ShadyDOM.noPatch` is set, this ensures that firing an event triggers distribution.
  • Loading branch information
Steven Orvell committed Jan 30, 2019
1 parent 8e50602 commit 491c2a7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
3 changes: 1 addition & 2 deletions lib/legacy/legacy-element-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
import '@webcomponents/shadycss/entrypoints/apply-shim.js';

import { ElementMixin } from '../mixins/element-mixin.js';
import { GestureEventListeners } from '../mixins/gesture-event-listeners.js';
import { DirMixin } from '../mixins/dir-mixin.js';
Expand Down Expand Up @@ -403,7 +402,7 @@ export const LegacyElementMixin = dedupingMixin((base) => {
});
event.detail = detail;
let node = options.node || this;
node.dispatchEvent(event);
wrap(node).dispatchEvent(event);
return event;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/mixins/property-effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*/

import '../utils/boot.js';

import { wrap } from '../utils/wrap.js';
import { dedupingMixin } from '../utils/mixin.js';
import { root, isAncestor, isDescendant, get, translate, isPath, set, normalize } from '../utils/path.js';
/* for notify, reflect */
Expand Down Expand Up @@ -296,7 +296,7 @@ function dispatchNotifyEvent(inst, eventName, value, path) {
if (path) {
detail.path = path;
}
/** @type {!HTMLElement} */(inst).dispatchEvent(new CustomEvent(eventName, { detail }));
wrap(/** @type {!HTMLElement} */(inst)).dispatchEvent(new CustomEvent(eventName, { detail }));
}

/**
Expand Down
3 changes: 2 additions & 1 deletion lib/utils/gestures.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import './boot.js';
import { timeOut, microTask } from './async.js';
import { Debouncer } from './debounce.js';
import { passiveTouchGestures } from './settings.js';
import { wrap } from './wrap.js';

// detect native touch action support
let HAS_NATIVE_TA = typeof document.head.style.touchAction === 'string';
Expand Down Expand Up @@ -659,7 +660,7 @@ export function setTouchAction(node, value) {
function _fire(target, type, detail) {
let ev = new Event(type, { bubbles: true, cancelable: true, composed: true });
ev.detail = detail;
target.dispatchEvent(ev);
wrap(target).dispatchEvent(ev);
// forward `preventDefault` in a clean way
if (ev.defaultPrevented) {
let preventer = detail.preventer || detail.sourceEvent;
Expand Down

0 comments on commit 491c2a7

Please sign in to comment.