bug: rel is not applied to the link in ion-breadcrumb and ion-item-option
Prerequisites
- [x] I have read the Contributing Guidelines.
- [x] I agree to follow the Code of Conduct.
- [x] I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
v9.x
Current Behavior
ion-breadcrumb and ion-item-option both have a documented rel prop ("Specifies the relationship of the target object to the link object."). When href is set, the <a> they render does not get the rel attribute. download, href and target are passed to the <a>, but rel is not.
ion-button and ion-item pass rel to their <a>.
Expected Behavior
The <a> inside ion-breadcrumb and ion-item-option has the rel value, as in ion-button and ion-item.
Steps to Reproduce
- Save the page below as
index.htmland open it in a browser. - Inspect the
<a>in the shadow root of each component. - Observe:
ion-breadcrumb:<a href="/docs" target="_blank">, norelion-item-option:<a href="/docs" target="_blank">, norelion-button:<a href="/docs" target="_blank" rel="nofollow">
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/[email protected]/css/ionic.bundle.css" />
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/[email protected]/dist/ionic/ionic.esm.js"></script>
</head>
<body>
<ion-breadcrumbs>
<ion-breadcrumb href="/docs" rel="nofollow" target="_blank">Docs</ion-breadcrumb>
</ion-breadcrumbs>
<ion-list>
<ion-item-sliding>
<ion-item><ion-label>Row</ion-label></ion-item>
<ion-item-options>
<ion-item-option href="/docs" rel="nofollow" target="_blank">Open</ion-item-option>
</ion-item-options>
</ion-item-sliding>
</ion-list>
<ion-button href="/docs" rel="nofollow" target="_blank">Button</ion-button>
</body>
</html>
Code Reproduction URL
No hosted app: the page above is the reproduction. It only needs the CDN build.
Ionic Info
@ionic/core 9.0.10 from the CDN, in Chromium. No Ionic CLI project is involved, so there is no ionic info output. Also reproduced on main (c6680bb) with spec tests.
Additional Information
In breadcrumb.tsx and item-option.tsx, the attrs object for the <a> lists download, href and target, but not rel. I'm opening a PR with spec tests.
AI-assisted: found and reproduced with an AI coding agent; the example above was run locally.
I'm working on this and will open a PR with spec tests shortly.
Thanks for the report, and for opening the fix.
Verified on 9.0.10. ion-breadcrumb and ion-item-option accept a rel prop but only copy download, href and target onto the <a> they render, so rel is dropped. The other components with a rel prop (ion-button, ion-item, ion-card, ion-fab-button, ion-tab-button, ion-router-link) all pass it through.
Until the fix ships, you can copy rel onto the inner link once the components have rendered. Ionic does not manage that attribute, so it survives later re-renders:
const applyRel = async () => {
const els = document.querySelectorAll('ion-breadcrumb[href][rel], ion-item-option[href][rel]');
for (const el of els) {
await el.componentOnReady();
const link = el.shadowRoot.querySelector('a');
if (link) {
link.setAttribute('rel', el.rel);
}
}
};
applyRel();
Run it again after adding new breadcrumbs or options, or after changing rel. For target="_blank" links, browsers already apply noopener by default, so what you lose in the meantime is noreferrer, nofollow and similar values.
The fix is in #31726, which we will review there.
Hey, thanks for the report! This issue was fixed in v9.0.13!