Skip to content

Commit

Permalink
add facing-metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
ruojianll committed Oct 28, 2023
1 parent cb8c1fe commit 258ff66
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
8 changes: 7 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
"peerDependencies": {
"vue": "^3.0.0"
},
"dependencies": {
"facing-metadata": "^1.0.1"
},
"devDependencies": {
"@types/chai": "^4.3.1",
"@types/mocha": "^9.1.1",
Expand All @@ -53,4 +56,4 @@
"type": "git",
"url": "git@github.com:facing-dev/vue-facing-decorator.git"
}
}
}
9 changes: 5 additions & 4 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Metadata } from 'facing-metadata'
import { Base } from './index'
import type { BaseTypeIdentify } from './index'
import type { InjectConfig } from "./option/inject";
Expand Down Expand Up @@ -29,7 +30,6 @@ export type SlotMapTypes = {
setup: Map<string, SetupConfig>
customDecorator: Map<string, CustomDecoratorRecord[]>
}

class Slot {
master: any
constructor(master: any) {
Expand All @@ -52,6 +52,8 @@ class Slot {
cachedVueComponent: any = null
}

const metadata = new Metadata<Slot>(SlotSymbol)

export function makeSlot(obj: any, defaultSlot?: Slot): Slot {
if (getSlot(obj)) {
throw ''
Expand All @@ -69,8 +71,7 @@ export function makeSlot(obj: any, defaultSlot?: Slot): Slot {
}

export function getSlot(obj: any): Slot | undefined {

return Object.getOwnPropertyDescriptor(obj, SlotSymbol)?.value
return metadata.getOwn(obj)
}

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

0 comments on commit 258ff66

Please sign in to comment.