Skip to content

Commit 258ff66

Browse files
committed
add facing-metadata
1 parent cb8c1fe commit 258ff66

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

package-lock.json

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
"peerDependencies": {
3333
"vue": "^3.0.0"
3434
},
35+
"dependencies": {
36+
"facing-metadata": "^1.0.1"
37+
},
3538
"devDependencies": {
3639
"@types/chai": "^4.3.1",
3740
"@types/mocha": "^9.1.1",
@@ -53,4 +56,4 @@
5356
"type": "git",
5457
"url": "[email protected]:facing-dev/vue-facing-decorator.git"
5558
}
56-
}
59+
}

src/utils.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Metadata } from 'facing-metadata'
12
import { Base } from './index'
23
import type { BaseTypeIdentify } from './index'
34
import type { InjectConfig } from "./option/inject";
@@ -29,7 +30,6 @@ export type SlotMapTypes = {
2930
setup: Map<string, SetupConfig>
3031
customDecorator: Map<string, CustomDecoratorRecord[]>
3132
}
32-
3333
class Slot {
3434
master: any
3535
constructor(master: any) {
@@ -52,6 +52,8 @@ class Slot {
5252
cachedVueComponent: any = null
5353
}
5454

55+
const metadata = new Metadata<Slot>(SlotSymbol)
56+
5557
export function makeSlot(obj: any, defaultSlot?: Slot): Slot {
5658
if (getSlot(obj)) {
5759
throw ''
@@ -69,8 +71,7 @@ export function makeSlot(obj: any, defaultSlot?: Slot): Slot {
6971
}
7072

7173
export function getSlot(obj: any): Slot | undefined {
72-
73-
return Object.getOwnPropertyDescriptor(obj, SlotSymbol)?.value
74+
return metadata.getOwn(obj)
7475
}
7576

7677
export function obtainSlot(obj: any, defaultSlot?: Slot): Slot {
@@ -127,7 +128,7 @@ export function excludeNames(names: string[], slot: Slot, filter?: (mapName: str
127128
if (mapName === 'customDecorator') {
128129
const map = currSlot.obtainMap('customDecorator')
129130
if (map.has(name)) {
130-
if (map.get(name)!.every(ite=>!ite.preserve)) {
131+
if (map.get(name)!.every(ite => !ite.preserve)) {
131132
return false
132133
} else {
133134
continue

0 commit comments

Comments
 (0)