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

Make renderCodicons function return HTMLElement instead of string #105589

Merged
merged 1 commit into from Sep 1, 2020

Conversation

annkamsk
Copy link
Contributor

This PR fixes #105588. This change includes a new version of renderCodicons function that deals with HTMLElements instead of string with embedded html tags.

@annkamsk
Copy link
Contributor Author

@jrieken hi, it might be a good place to also discuss an issue I stumbled upon. In this case, the original renderCodicons functions and the whole codicons.ts file is placed in vs/base/common/ module. From there it's not possible to import $, reset, append or any other function from dom.ts as it's placed in browser directory. Here, I solved this problem by creating a new codicons.ts file inside vs/base/browser, but let me know what's your preferred solution.
However, in many other cases (eg. codelensWidget.ts, viewLineRenderer.ts#renderViewLine to name a few) which are placed outside of browser directory, but require usage of $, I can't see any general solution. Do you have any idea how to tackle that problem? Or maybe there's no one way and it's better if we discuss each of the cases in a separate issue.

@RMacfarlane RMacfarlane requested review from joaomoreno and removed request for joaomoreno August 28, 2020 15:50
@jrieken jrieken added this to the August 2020 milestone Aug 31, 2020
@jrieken
Copy link
Member

jrieken commented Aug 31, 2020

Here, I solved this problem by creating a new codicons.ts file inside vs/base/browser, but let me know what's your preferred solution.

I think that's good like that. An alternative would be src/vs/base/browser/ui/codicons/ but moving things around later is not hard.

However, in many other cases (eg. codelensWidget.ts, viewLineRenderer.ts#renderViewLine to name a few) which are placed outside of browser directory, but require usage of $, I can't see any general solution

We have a "special" rule that says that everything inside "editor/contrib" is implicitly in the browser layer. It shouldn't generate a warning when importing from base/browser-layers there. Tho, I would suggest that we leave the rest of the renderCodicon-adoption to the team. It is a good and simple enough sample to get everyone involved into the trusted types effort.

Copy link
Member

@jrieken jrieken left a comment

Choose a reason for hiding this comment

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

looking good

@jrieken jrieken merged commit 11479ca into microsoft:master Sep 1, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Oct 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trusted Types compatibility: renderCodicons – return HTMLElement instead of string
2 participants