From 684284959ea635e76ee206d8be8bc5c6f7ba8652 Mon Sep 17 00:00:00 2001 From: yaoyuchi Date: Mon, 14 Mar 2022 14:27:28 +0800 Subject: [PATCH] custom component support inhert css Signed-off-by: yaoyuchi --- runtime/main/model/directive.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/runtime/main/model/directive.ts b/runtime/main/model/directive.ts index 9167466c..7d498618 100644 --- a/runtime/main/model/directive.ts +++ b/runtime/main/model/directive.ts @@ -160,6 +160,23 @@ export function bindSubVm(vm: Vm, rawSubVm: Vm, rawTemplate: TemplateInterface, mergePropsObject(key, value, vm, subVm); }); } + + const attr = template.attr || {}; + for (const key in attr) { + const value = attr[key]; + if (key === 'inhertClass') { + const inhertClasss = value.split(' '); + for (let x = 0; x < inhertClasss.length; x++) { + const cssName = '.' + inhertClasss[x]; + const cssParent = vm._css[cssName]; + if (cssParent) { + subVm._css[cssName] = cssParent; + } else { + console.error('cssParent is null'); + } + } + } + } } /**