-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(react): add View component to proxy react event to process stopPr…
…opagation, close #973
- Loading branch information
Showing
3 changed files
with
44 additions
and
1 deletion.
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,24 @@ | ||
import { Component, createVNode as h, TypeDefs } from 'intact'; | ||
|
||
export interface ViewProps { | ||
tag?: string, | ||
} | ||
|
||
const typeDefs: Required<TypeDefs<ViewProps>> = { | ||
tag: String, | ||
}; | ||
|
||
/** | ||
* A component only used in React or Vue to bind event, so that | ||
* it can use Intact Event system to stop propagation (stopPropagation). | ||
*/ | ||
export class View extends Component<ViewProps> { | ||
static template(this: View) { | ||
const { tag, ...rest } = this.get(); | ||
return h(tag!, rest as any); | ||
} | ||
static typeDefs = typeDefs; | ||
static defaults() { | ||
return { tag: 'div' }; | ||
} | ||
} |
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
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