Skip to content

Commit e5a1491

Browse files
committed
chore: remove legacy node attributes deprecation
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
1 parent fd3a895 commit e5a1491

File tree

2 files changed

+6
-29
lines changed

2 files changed

+6
-29
lines changed

__tests__/files/node.spec.ts

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -820,26 +820,9 @@ describe('Attributes update', () => {
820820
})
821821

822822
expect(file.attributes?.etag).toBe('5678')
823-
expect(file.attributes?.size).toBe(9999)
824-
expect(file.attributes?.owner).toBe('emma')
825-
expect(file.attributes?.fileid).toBeUndefined()
826-
})
827-
828-
test('Deprecated access to toplevel attributes', () => {
829-
const spy = vi.spyOn(window.console, 'warn')
830-
const file = new File({
831-
source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg',
832-
mime: 'image/jpeg',
833-
owner: 'emma',
834-
size: 9999,
835-
attributes: {
836-
etag: '1234',
837-
size: 9999,
838-
},
839-
})
840-
841-
expect(file.attributes.size).toBe(9999)
842-
expect(spy).toBeCalledTimes(1)
823+
expect(file?.size).toBe(9999)
824+
expect(file?.owner).toBe('emma')
825+
expect(file?.fileid).toBeUndefined()
843826
})
844827

845828
test('Changing a protected attributes is not possible', () => {
@@ -853,9 +836,10 @@ describe('Attributes update', () => {
853836
})
854837

855838
// We can not update the owner
856-
expect(() => { file.attributes.owner = 'admin' }).toThrowError()
839+
// @ts-expect-error owner is a read-only property
840+
expect(() => { file.owner = 'admin' }).toThrowError()
857841
// The owner is still the original one
858-
expect(file.attributes?.owner).toBe('emma')
842+
expect(file?.owner).toBe('emma')
859843
})
860844

861845
})

lib/node/node.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,7 @@ export abstract class Node {
5151
// Apply original changes
5252
return Reflect.deleteProperty(target, prop)
5353
},
54-
// TODO: This is deprecated and only needed for files v3
5554
get: (target: Attribute, prop: string, receiver) => {
56-
if (this.readonlyAttributes.includes(prop)) {
57-
logger.warn(`Accessing "Node.attributes.${prop}" is deprecated, access it directly on the Node instance.`)
58-
return Reflect.get(this, prop)
59-
}
6055
return Reflect.get(target, prop, receiver)
6156
},
6257
} as ProxyHandler<Attribute>
@@ -74,8 +69,6 @@ export abstract class Node {
7469
validateData(data, davService)
7570

7671
this._data = {
77-
// TODO: Remove with next major release, this is just for compatibility
78-
displayname: data.attributes?.displayname,
7972
...data,
8073
attributes: {},
8174
}

0 commit comments

Comments
 (0)