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

GmailJS method add_toolbar_button is not working #788

Open
shashikiran-im opened this issue Mar 27, 2024 · 5 comments
Open

GmailJS method add_toolbar_button is not working #788

shashikiran-im opened this issue Mar 27, 2024 · 5 comments

Comments

@shashikiran-im
Copy link
Contributor

Hi GmailJS Team,

FYI that I had updated code to refer jQuery & added below code & it is working,
const trustedHTMLpolicy = trustedTypes.createPolicy("default", {
createHTML: (to_escape) => to_escape,
});

$.extend({
htmlPrefilter: trustedHTMLpolicy.createHTML // this is the actual function which jQuery needs
});

But gmail.tools.add_toolbar_button() method used to add buttons to toolbar is not working & showing below error in console,

jquery.module.min.js:2 Uncaught TypeError: Illegal invocation
at T.fn.init. (jquery.module.min.js:2:44823)
at Y (jquery.module.min.js:2:6326)
at T.fn.init.html (jquery.module.min.js:2:44634)
at create_generic_toolbar_button (gmail.js:3673:16)
at Gmail.api.tools.add_toolbar_button (gmail.js:3690:16)
at extension.js:25:19
at gmail.js:2745:28

Please let me know how to address it.

Thanks in Advance,
Shashikiran

@josteink
Copy link
Collaborator

Please read thread about TrustedHTML.

It's mentioned there.

@shashikiran-im
Copy link
Contributor Author

Hi @josteink,

Thanks for reply.
I tried JQuery 4 beta & passed trusted HTML to GmailJS API method add_toolbar_button() & it worked.

Need Clarification:

  1. My Extension is in production and jQuery 4.0 version is still in beta version hence we thought we shouldn't use JQuery 4 beta it for production. Please let me know your comment on this.
  2. So if we want to remove JQuery dependency in GmailJS library then we should use DOM API's instead (as per your comment in issue 779 (Gmail change for innerHTML #779 (comment)), any guess on how much effort is required to do the change in Gmail JS library (to remove jQuery dependency & use DOM API's instead).

Thanks in Advance,
Shashikiran

@josteink
Copy link
Collaborator

josteink commented Apr 9, 2024

  1. While you ideally wouldnt want to use beta-software in production, the situation is that jQuery 4 works, and jQuery 3 doesnt. That makes it a pretty simple choice.
  2. Its going to be quite a bit of effort, because we want to maintain compatibility with existing extensions without breaking them (provide adapters for new or OLD api. Right now nobody is working on it yet, so hard to say anything definite.

@canibanoglu
Copy link

Please read thread about TrustedHTML.

It's mentioned there.

What thread are you referring to?

@josteink
Copy link
Collaborator

This thread: #779

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants