Skip to content

Commit

Permalink
Merge branch 'next'
Browse files Browse the repository at this point in the history
  • Loading branch information
toxic-johann committed Jul 31, 2017
2 parents 6b67621 + 8b4893d commit 900be53
Show file tree
Hide file tree
Showing 11 changed files with 804 additions and 3 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ doc/
flow/
node_modules/
tool/
bundle-size/
.babelrc
.flowconfig
26 changes: 26 additions & 0 deletions __tests__/bugfix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Chimee from 'index';
test('redudant event bind on video', () => {
const wrapper = document.createElement('div');
const fn = jest.fn();
const cfn = jest.fn();
const wfn = jest.fn();
const plugin = {
name: 'redudantEventBind',
events: {
click: fn,
c_click: cfn,
w_click: wfn
}
};
Chimee.install(plugin);
const player = new Chimee({
wrapper,
plugin: ['redudantEventBind']
});
player.__dispatcher.dom.videoElement.dispatchEvent(new Event('click'));
expect(fn).toHaveBeenCalledTimes(1);
player.__dispatcher.dom.container.dispatchEvent(new Event('click'));
expect(cfn).toHaveBeenCalledTimes(1);
player.__dispatcher.dom.wrapper.dispatchEvent(new Event('click'));
expect(wfn).toHaveBeenCalledTimes(1);
});
4 changes: 4 additions & 0 deletions build/rollup.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import babel from 'rollup-plugin-babel';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import replace from 'rollup-plugin-replace';
import visualizer from 'rollup-plugin-visualizer';
const babelConfig = {
common: {
presets: [
Expand Down Expand Up @@ -83,6 +84,9 @@ export default function (mode) {
commonjs(),
replace({
'process.env.PLAYER_VERSION': `'${version}'`
}),
visualizer({
filename: `bundle-size/${mode}.html`
})
]
};
Expand Down
152 changes: 152 additions & 0 deletions bundle-size/common.html

Large diffs are not rendered by default.

152 changes: 152 additions & 0 deletions bundle-size/es.html

Large diffs are not rendered by default.

152 changes: 152 additions & 0 deletions bundle-size/iife.html

Large diffs are not rendered by default.

152 changes: 152 additions & 0 deletions bundle-size/min.html

Large diffs are not rendered by default.

152 changes: 152 additions & 0 deletions bundle-size/umd.html

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions demo/base/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
},
c_contextmenu (evt) {
console.log(evt);
},
c_click (evt) {
console.warn(evt);
},
click (evt) {
console.log(evt);
}
}
};
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"rollup-plugin-replace": "^1.1.1",
"rollup-plugin-serve": "^0.4.0",
"rollup-plugin-uglify": "^2.0.1",
"rollup-plugin-visualizer": "^0.3.1",
"rollup-watch": "^4.3.1"
},
"jest": {
Expand Down
9 changes: 6 additions & 3 deletions src/dispatcher/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,12 @@ export default class Dom {
*/
this.installVideo(videoElement);
domEvents.forEach(key => {
const fn = this._getEventHandler(key, {penetrate: true});
this.videoDomEventHandlerList.push(fn);
addEvent(this.videoElement, key, fn);
const cfn = (...args) => this.__dispatcher.bus.triggerSync('c_' + key, ...args);
this.containerDomEventHandlerList.push(cfn);
addEvent(this.container, key, cfn);
const wfn = (...args) => this.__dispatcher.bus.triggerSync('w_' + key, ...args);
this.wrapperDomEventHandlerList.push(wfn);
addEvent(this.wrapper, key, wfn);
});
this._bindFullScreen();
}
Expand Down

0 comments on commit 900be53

Please sign in to comment.