Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to remove extensions from item #49

Open
ransome1 opened this issue Oct 10, 2023 · 2 comments
Open

A way to remove extensions from item #49

ransome1 opened this issue Oct 10, 2023 · 2 comments

Comments

@ransome1
Copy link

In the next branch, you can set an extension like item.setExtension('pri', 'A');

Once it is set, you can null the value, but you can't remove the whole extension object. So even if you set the extension to null, it will be part of item.toString(): pri:null

We might want to think about a way to remove extensions, like item.removeExtension('pri');

@madeindjs
Copy link
Contributor

@ransome1 , it seems to be possible, you simply need to specify the value of the extension like

item.removeExtension('pri', 'A');

There is a test which cover that

test('removeExtension › Removes the extension by key and value', (t) => {
const item = new Item('My room:kitchen wall is painted color:blue and color:red');
item.removeExtension('color', 'blue');
t.deepEqual(item.extensions(), [
{ key: 'room', value: 'kitchen' },
{ key: 'color', value: 'red' },
]);
t.is(item.body(), 'My room:kitchen wall is painted and color:red');
});

@jmhobbs
Copy link
Owner

jmhobbs commented Jan 17, 2025

Would it make sense to add an affordance for that (and perhaps other tags?) where a set operation with a null or undefined value is converted to a remove operation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants