Skip to content

fix(aio): preserve newlines when copying code - #17674

Merged
matsko merged 1 commit into
angular:masterfrom
gkalpak:fix-aio-copy-linenums
Jun 23, 2017
Merged

matsko merged 1 commit into
angular:masterfrom
gkalpak:fix-aio-copy-linenums

Conversation

@gkalpak

@gkalpak gkalpak commented Jun 21, 2017

Copy link
Copy Markdown
Member

Before 4f37f86, we were using innerText to retrieved the code content for copying. This preserved the text layout (including newlines), but suffered from other issues (browser support, performance). With 4f37f86 we switched to textContent, which works well except in the following case:
When prettify formats the code to have line numbers, it removes the newlines and uses <li> elements instead. This affects textContent.

This commit fixes this by keeping a reference of the code as text and using that
for copying.

Fixes #17659.

Before 4f37f86, we were using `innerText` to retrieved the code content for
copying. This preserved the text layout (including newlines), but suffered from
other issues (browser support, performance). With 4f37f86 we switched to
`textContent`, which works well except in the following case:
When `prettify` formats the code to have line numbers, it removes the newlines
and uses `<li>` elements instead. This affects `textContent`.

This commit fixes this by keeping a reference of the code as text and using that
for copying.

Fixes angular#17659
@gkalpak gkalpak added comp: aio action: review The PR is still awaiting reviews from at least one requested reviewer and removed cla: yes labels Jun 21, 2017
@mary-poppins

Copy link
Copy Markdown

The angular.io preview for 4923eb4 is available here.

@petebacondarwin petebacondarwin added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jun 23, 2017
@matsko
matsko merged commit 87206e1 into angular:master Jun 23, 2017
@gkalpak
gkalpak deleted the fix-aio-copy-linenums branch June 23, 2017 19:52
@angular-automatic-lock-bot

Copy link
Copy Markdown

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 11, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aio: copy button doesn't work correctly in some examples

5 participants