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

Iss1410 #3256

Closed
wants to merge 2 commits into from
Closed

Iss1410 #3256

wants to merge 2 commits into from

Conversation

CreaTorAlexander
Copy link
Contributor

Fixes #1410

Instead of using the onclick html attribute here we use an eventlistener

I don't know why the other commit with #2658 is here it should already merged, but idk how to remove this commit.

Instead of using onclick html attribute used here an event listener
@CreaTorAlexander CreaTorAlexander requested a review from a team as a code owner March 18, 2021 07:54
@CreaTorAlexander CreaTorAlexander requested review from a team, ericwbailey and chrisdavidmills and removed request for a team March 18, 2021 07:54
Copy link
Contributor

@chrisdavidmills chrisdavidmills left a comment

Choose a reason for hiding this comment

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

@CreaTorAlexander there are a couple of problems here, and this code snippet won't work as it stands:

  1. Document.querySelector() doesn't take a second argument of a function to invoke. You'd have to do this using something like addEventListener() instead.
  2. addAttribute() doesn't exist — setAttribute() is what you need.

the following works:

const btn = document.querySelector('button');
btn.addEventListener('click', triggerAlert);

function triggerAlert() {
  var alertEl = document.querySelector('.alert');
  console.log(alertEl)
  alertEl.setAttribute('role', 'alert');
}

Make sure you test code snippets before submitting.

@CreaTorAlexander
Copy link
Contributor Author

CreaTorAlexander commented Mar 18, 2021

Damn sorry, did it in the GitHub UI what was obviously here a mistake.
I will update it later on.

@chrisdavidmills
Copy link
Contributor

Damn sorry, did it in the GitHub UI what was obviously here a mistake.
I will update it later on.

No need to apologize at all. We all make mistakes sometimes, and what you do for us is hugely helpful.

@CreaTorAlexander
Copy link
Contributor Author

@chrisdavidmills is there a reason for the console.log?

@chrisdavidmills
Copy link
Contributor

@chrisdavidmills is there a reason for the console.log?

Oh, no, there isn't! That was leftover from a test I did. you can remove that ;-)

@CreaTorAlexander
Copy link
Contributor Author

Okay, I assumed it so I already did a PR. #3270

@ericwbailey ericwbailey removed their request for review March 19, 2021 00:29
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 11, 2022
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.

addAttribute or setAttribute
2 participants