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

fix(aio): only remove the header-link from toc titles #22504

Conversation

petebacondarwin
Copy link
Member

The previous approach just removed the first a tag that
was found, but now that the header-link anchor is not at
the start of the heading, it could fail.

Closes #22493

@petebacondarwin petebacondarwin added type: bug/fix action: review The PR is still awaiting reviews from at least one requested reviewer comp: aio target: major This PR is targeted for the next major release labels Feb 28, 2018
@petebacondarwin petebacondarwin added this to REVIEW in docs-infra Feb 28, 2018
@mary-poppins
Copy link

You can preview 7c69b2e at https://pr22504-7c69b2e.ngbuilds.io/.

const a = this.document.createElement('a') as HTMLAnchorElement;
a.innerHTML = heading.innerHTML;
const anchorLink = a.querySelector('a');
const div = this.document.createElement('div') as HTMLAnchorElement;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cast to HTMLAnchorElement is wrong (and seems unnecessary anyway).

@gkalpak gkalpak added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Mar 1, 2018
@petebacondarwin
Copy link
Member Author

Actually, I think this PR is wrong as it stands as we should really be removing all links from the HTML that is copied over. Otherwise you have links inside a link which doesn't make sense, right?

throw new Error('$lastInfo is not yet defined. You must call `spyOn` first.');
}
return this.$$lastInfo;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this stuff is just to get around strict null checks, which are not yet turned on it seems.

@petebacondarwin petebacondarwin added action: review The PR is still awaiting reviews from at least one requested reviewer and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Mar 1, 2018
@petebacondarwin
Copy link
Member Author

@gkalpak PTAL

@mary-poppins
Copy link

You can preview dd39032 at https://pr22504-dd39032.ngbuilds.io/.

a.removeChild(anchorLink);
const div: HTMLDivElement = this.document.createElement('div');
div.innerHTML = heading.innerHTML;
const anchorLinks: NodeListOf<HTMLAnchorElement> = div.querySelectorAll('a');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OOC: Are the HTMLDivElement (above) and NodeListOf<HTMLAnchorElement> types necessary? Latest TS can infer them. (Maybe time to upgrade 😁)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'tis true but we haven't upgraded yet!

@gkalpak gkalpak added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Mar 1, 2018
@petebacondarwin
Copy link
Member Author

Just realised that I need to change the commit message - since the solution is now different. I will rebase and squash when doing so.

The previous approach just removed the first `a` tag that
was found, but now that the header-link anchor is not at
the start of the heading, it could fail.

Closes angular#22493
@petebacondarwin petebacondarwin added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Mar 1, 2018
@petebacondarwin petebacondarwin moved this from REVIEW to MERGE in docs-infra Mar 1, 2018
@mary-poppins
Copy link

You can preview 69fd953 at https://pr22504-69fd953.ngbuilds.io/.

@petebacondarwin petebacondarwin deleted the aio-remove-heading-anchor branch March 1, 2018 19:06
@petebacondarwin petebacondarwin removed this from MERGE in docs-infra Mar 1, 2018
@petebacondarwin petebacondarwin added this to MERGE in docs-infra Mar 1, 2018
@petebacondarwin
Copy link
Member Author

I accidentally deleted the branch for this PR, which closed this PR. I reinstated the branch but I don't seem to be able to reopen the PR. I will open a new one.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes target: major This PR is targeted for the next major release type: bug/fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Documentation error
4 participants