-
Notifications
You must be signed in to change notification settings - Fork 83
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
feat: add target property to side-nav-item #7088
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -292,5 +292,27 @@ describe('side-nav-item', () => { | |
toggle.click(); | ||
expect(spy.called).to.be.false; | ||
}); | ||
|
||
describe('target property', () => { | ||
it('should set target attribute to the anchor when target is set', async () => { | ||
item.target = '_blank'; | ||
await nextRender(); | ||
expect(anchor.getAttribute('target')).to.be.equal('_blank'); | ||
}); | ||
|
||
it('should remove target attribute from the anchor when target is removed', async () => { | ||
item.target = '_blank'; | ||
await nextRender(); | ||
item.target = null; | ||
await nextRender(); | ||
expect(anchor.getAttribute('target')).to.be.not.ok; | ||
}); | ||
|
||
it('should not set target attribute to the anchor when target is empty string', async () => { | ||
item.target = ''; | ||
await nextRender(); | ||
expect(anchor.getAttribute('target')).to.be.not.ok; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From my testing the attribute is still defined for an empty string, the assertion here doesn't work as intended. Would be better to use If we want to avoid defining the attribute it requires further changes. Don't see why it would be necessary though. So maybe just remove the test case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, you're right. Based on this comment, I also changed the assertion in the previous test to use |
||
}); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be a type here that only accepts something like
'_self' | '_blank' | '_parent' | '_top'
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
target
inHTMLAnchoElement
doesn't seem to get any special type (source)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A niche use-case would be to configure a specific browsing context, which could have any name apparently (vaadin/flow-components#5091 (comment)). So the union type would need to include
string
as well. But just starting withstring
is fine IMO 👍