-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(okam-core): add native swan component adapter to okam
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @file Fix swan native component to adapt okam event handler. | ||
* @author [email protected] | ||
*/ | ||
|
||
'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; | ||
} | ||
|
||
|