-
Notifications
You must be signed in to change notification settings - Fork 59
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
Issue/209 #231
Issue/209 #231
Conversation
packages/metal-dom/src/domNamed.js
Outdated
@@ -340,7 +340,18 @@ export function hasClass(element, className) { | |||
* @private | |||
*/ | |||
function hasClassWithNative_(element, className) { | |||
return element.classList.contains(className); | |||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try/catch won't be optimized in browsers, would be better to check for presence of element.classList
.
Ok, I have updated my PR and:
|
Hey @Robert-Frampton, this should be good to go. Care to take a look and merge if all seems fine? Thanks! |
Why not remove the try catch block and check for whitespace in function hasClassWithNative_(element, className) {
return className.indexOf(' ') < 0 && element.classList.contains(className);
} That way there is no error to catch. |
@Robert-Frampton you are totally right. I will modify the PR and notify you in a couple of days. Thanks for the correction :) |
Now the pass the given test. For the case of hasClassWithNative_, it tries to use the native methods, but catches a dom exception with the text "contains HTML space characters", other exceptions are thrown.
@Robert-Frampton ready to go |
LGTM. |
Hey guys, should we close #209 as well? |
Yeah, done! 😉 |
These commits solve the report described con #209, however, there are three things pending before finishing:
MDN DOMException docs: https://developer.mozilla.org/en-US/docs/Web/API/DOMException
MSDN DOMException docs: https://msdn.microsoft.com/es-es/library/ff974354(v=vs.85).aspx