Hacker News new | past | comments | ask | show | jobs | submit login

Thanks for the link, I've went ahead and made it work on any input field and text area that isn't in the not allowed list.



Don't forget select elements too. An easier way for you to do your whole extension could be to use an XPath expression or `document.querySelectorAll('textarea, select, input:not([type="' + notAllowed.join('"]):not([type="') + '"])')` (results in `textarea, select, input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="image"]):not([type="reset"]):not([type="button"]))`). Also, may I ask why are you abstracting Array.indexOf away and extending the Array prototype with a non-standard method for such a simple problem?


Your line of code is so long it's causing this Hacker News comments page to have horizontal scrolling! I've never seen that before. :)

In case you didn't know, HN will format code if you prefix it with two spaces like this:

  document.querySelectorAll('textarea, select, input:not([type="' + notAllowed.join('"]):not([type="') + '"])') (results in `textarea, select, input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="image"]):not([type="reset"]):not([type="button"]))`)
It can preserve indentation too:

  document.querySelectorAll(
    'textarea, select, input:not([type="' 
    + notAllowed.join('"]):not([type="') 
    + '"])')


  Also, may I ask why are you abstracting Array.indexOf away and extending the Array prototype with a non-standard method for such a simple problem?
Mostly a personal preference, I guess, haven't looked into the downsides of extending prototypes.

Anywho, I'm fairly new at JS outside of jQuery, so thanks for your input and critiques. I'll look into the rest when I get back from dinner.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: