зеркало из https://github.com/github/catalyst.git
ensure marks default to configurable+enumerable
This commit is contained in:
Родитель
c12f5b7914
Коммит
b34abdd9a5
|
@ -60,7 +60,7 @@ export function createMark<T extends object>(
|
|||
enumerable: true
|
||||
}
|
||||
const newDescriptor = initialize(instance, {name, kind: getType(access), access}) || access
|
||||
Object.defineProperty(instance, name, newDescriptor)
|
||||
Object.defineProperty(instance, name, Object.assign({configurable: true, enumerable: true}, newDescriptor))
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
22
test/mark.ts
22
test/mark.ts
|
@ -231,4 +231,26 @@ describe('createMark', () => {
|
|||
expect(initialize).to.be.calledWithExactly(fooBar, {name: 'grault', kind: 'method', access: accessFor('grault')})
|
||||
expect(initialize).to.be.calledWithExactly(fooBar, {name: sym, kind: 'method', access: accessFor(sym)})
|
||||
})
|
||||
|
||||
it('can apply multiple different marks to the same property', () => {
|
||||
const [mark1, getMarks1, initializeMarks1] = createMark(
|
||||
fake(),
|
||||
fake(() => ({get: fake(), set: fake()}))
|
||||
)
|
||||
const [mark2, getMarks2, initializeMarks2] = createMark(
|
||||
fake(),
|
||||
fake(() => ({get: fake(), set: fake()}))
|
||||
)
|
||||
class FooBar {
|
||||
@mark1 @mark2 foo: unknown
|
||||
@mark2 @mark1 bar = 'hi'
|
||||
constructor() {
|
||||
initializeMarks1(this)
|
||||
initializeMarks2(this)
|
||||
}
|
||||
}
|
||||
const fooBar = new FooBar()
|
||||
expect(Array.from(getMarks1(fooBar))).to.eql(['foo', 'bar'])
|
||||
expect(Array.from(getMarks2(fooBar))).to.eql(['foo', 'bar'])
|
||||
})
|
||||
})
|
||||
|
|
Загрузка…
Ссылка в новой задаче