Skip to content

Commit

Permalink
feat(okam-core): add native swan component adapter to okam
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhy committed Nov 7, 2018
1 parent f965a2d commit d1fa2ea
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions packages/okam-core/src/swan/adapter/component.js
@@ -0,0 +1,35 @@
/**
* @file Fix swan native component to adapt okam event handler.
* @author sparklewhy@gmail.com
*/

'use strict';

import {normalizeEventArgs} from '../../helper/triggerEvent';

/**
* Emit custom component event
*
* @param {...any} args the event arguments
*/
function emit(...args) {
// fix custom component event args
normalizeEventArgs(this, args);
this.triggerEvent.apply(this, args);
}

/**
* Make the native swan component to adapt to the okam framework
*
* @param {Object} component the component to adapt
* @return {Object}
*/
export default function adaptOKAM(component) {
let methods = component.methods || (component.methods = {});
if (!methods.$emit) {
methods.$emit = emit;
}
return component;
}


0 comments on commit d1fa2ea

Please sign in to comment.