From d635977224f9e4e0f68f07fc2b70a0f429dfe660 Mon Sep 17 00:00:00 2001 From: zoomchan-cxj Date: Wed, 26 Apr 2023 22:39:06 +0800 Subject: [PATCH] fix(vue): remove redundant props & perf cache logic --- .../hippy-vue-next-demo/src/main-native.ts | 37 ------------------- .../src/native-component/animation.ts | 1 - .../src/native-component/swiper.ts | 1 - .../src/runtime/node/hippy-node.ts | 3 +- 4 files changed, 2 insertions(+), 40 deletions(-) diff --git a/examples/hippy-vue-next-demo/src/main-native.ts b/examples/hippy-vue-next-demo/src/main-native.ts index 1a6bf9340a8..c5a252d7d96 100644 --- a/examples/hippy-vue-next-demo/src/main-native.ts +++ b/examples/hippy-vue-next-demo/src/main-native.ts @@ -93,43 +93,6 @@ const initCallback = ({ superProps, rootViewId }) => { // // mount app // app.mount('#root'); // }); - - // invoke custom native apis with type hints - Native.callNative('customModule', 'customMethod', '123', 456); - Native.callNativeWithPromise( - 'customModule', - 'customMethodWithPromise', - '123', - 456, - ).then((result) => { - console.log(result); - }); - - // register custom component with type inference - registerElement('customComponent', { - component: { - name: 'custom-component', - processEventData( - evtData: EventsUnionType, - nativeEventParams: { [key: string]: NeedToTyped }, - ) { - const { handler: event, __evt: nativeEventName } = evtData; - - switch (nativeEventName) { - // this can infer event is HippyTouchEvent from type narrowing - case 'onTest': - event.contentOffset = nativeEventParams.position; - break; - // extended HippyEvent which has testProp - case 'onAnotherTest': - event.testProp = 123; - break; - default: - } - return event; - }, - }, - }); }; // start hippy app diff --git a/packages/hippy-vue-next/src/native-component/animation.ts b/packages/hippy-vue-next/src/native-component/animation.ts index 1740629a538..5c4dc981e94 100644 --- a/packages/hippy-vue-next/src/native-component/animation.ts +++ b/packages/hippy-vue-next/src/native-component/animation.ts @@ -344,7 +344,6 @@ export function registerAnimation(vueApp: App): void { useAnimation: true, style: this.style, tag: this.$props.tag, - playing: this.$props.playing, ...this.$props.props, }, this.$slots.default ? this.$slots.default() : null, diff --git a/packages/hippy-vue-next/src/native-component/swiper.ts b/packages/hippy-vue-next/src/native-component/swiper.ts index ed2d1d344d7..64b8bc916dc 100644 --- a/packages/hippy-vue-next/src/native-component/swiper.ts +++ b/packages/hippy-vue-next/src/native-component/swiper.ts @@ -124,7 +124,6 @@ export function registerSwiper(vueApp: App): void { ...on, ref: 'swiper', initialPage: this.$initialSlide, - ...this.$props, }, this.$slots.default ? this.$slots.default() : null, ); diff --git a/packages/hippy-vue-next/src/runtime/node/hippy-node.ts b/packages/hippy-vue-next/src/runtime/node/hippy-node.ts index 53b1088badd..048b0f46f12 100644 --- a/packages/hippy-vue-next/src/runtime/node/hippy-node.ts +++ b/packages/hippy-vue-next/src/runtime/node/hippy-node.ts @@ -431,7 +431,7 @@ export class HippyNode extends HippyEventTarget { // if the root node is not rendered on the screen, start rendering from the root node first // render the child node if the child node is not rendered - renderInsertChildNativeNode(parentNode.convertToNativeNodes(true)); + const nodeList = parentNode.convertToNativeNodes(true); // update the isMounted flag parentNode.eachNode((rawNode: HippyNode) => { const node = rawNode; @@ -441,6 +441,7 @@ export class HippyNode extends HippyEventTarget { // cache the nodes inserted into the native to improve the search speed preCacheNode(node, node.nodeId); }); + renderInsertChildNativeNode(nodeList); } }