diff --git a/driver/js/packages/hippy-vue-next/src/runtime/element/hippy-element.ts b/driver/js/packages/hippy-vue-next/src/runtime/element/hippy-element.ts index bf915508bf3..a65fb125ddf 100644 --- a/driver/js/packages/hippy-vue-next/src/runtime/element/hippy-element.ts +++ b/driver/js/packages/hippy-vue-next/src/runtime/element/hippy-element.ts @@ -225,6 +225,9 @@ export class HippyElement extends HippyNode { // style public style: NativeNodeProps; + // processed style, to refactor on dom + public processedStyle: NativeNodeProps = {}; + // events map public events: NativeNodeProps; @@ -874,6 +877,19 @@ export class HippyElement extends HippyNode { // get styles let style: NativeNodeProps = this.getNativeStyles(); + if (this.parentNode && this.parentNode instanceof HippyElement) { + // 属性继承逻辑实现 + // 只继承 color 和 font属性 + const parentNodeStyle = this.parentNode.processedStyle; + const styleAttributes = ['color', 'fontSize', 'fontWeight', 'fontFamily', 'fontStyle', 'textAlign', 'lineHeight']; + + styleAttributes.forEach((attribute) => { + if (!style[attribute] && parentNodeStyle[attribute]) { + style[attribute] = parentNodeStyle[attribute]; + } + }); + } + getBeforeRenderToNative()(this, style); /* @@ -892,6 +908,8 @@ export class HippyElement extends HippyNode { style = { ...updateStyle, ...style }; } + this.processedStyle = style; + const elementExtraAttributes: Partial = { name: this.component.name, props: { diff --git a/driver/js/packages/hippy-vue-next/src/runtime/node/hippy-node.ts b/driver/js/packages/hippy-vue-next/src/runtime/node/hippy-node.ts index 3589cd4468f..49433e828c4 100644 --- a/driver/js/packages/hippy-vue-next/src/runtime/node/hippy-node.ts +++ b/driver/js/packages/hippy-vue-next/src/runtime/node/hippy-node.ts @@ -372,6 +372,7 @@ export class HippyNode extends HippyEventTarget { // In the case of keep-alive, the node still exists and will be moved to the virtual container if (child.parentNode && child.parentNode !== this) { child.parentNode.removeChild(child); + return; } // If the node is already mounted, remove it first, but do not remove when is hydrate.