Skip to content

Commit

Permalink
fix: use loader component with mark external
Browse files Browse the repository at this point in the history
  • Loading branch information
meixg committed Jun 1, 2022
1 parent d30ca64 commit ee53d66
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/parsers/component-class-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class ComponentClassParser {

const components: { [key: string]: Component<{}> | undefined } =
getMemberFromClass(parentComponentClass, 'components', {})
for (const [tagName, componentClass] of Object.entries(components)) {
for (let [tagName, componentClass] of Object.entries(components)) {
if (!componentClass) {
continue
}
Expand All @@ -115,6 +115,10 @@ export class ComponentClassParser {
continue
}

if (isComponentLoader(componentClass) && componentClass.placeholder) {
componentClass = componentClass.placeholder
}

// 外部组件
if (componentClass[COMPONENT_REFERENCE]) {
children.set(tagName, componentClass[COMPONENT_REFERENCE])
Expand All @@ -124,7 +128,7 @@ export class ComponentClassParser {
// 可能是空,例如 var Foo = defineComponent({components: {foo: Foo}})
children.set(tagName, new DynamicComponentReference(
'.',
componentID(componentClass === this.root, () => this.getOrSetID(componentClass)),
componentID(componentClass === this.root, () => this.getOrSetID(componentClass as Component<{}>)),
componentClass
))
}
Expand Down
2 changes: 1 addition & 1 deletion test/cases/external-placeholder/component.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const san = require('san')
const ChildA = require('./childA.san.js')
const ChildA = require('./childA.san')

const MyComponent = san.defineComponent({
components: {
Expand Down
1 change: 1 addition & 0 deletions test/cases/external-placeholder/expected.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div><div>aaa</div></div>

0 comments on commit ee53d66

Please sign in to comment.