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

Simple.js adds undefined as a placeholder where no placeholder attribute exists #11

Open
adrianosmond opened this issue Mar 25, 2015 · 3 comments

Comments

@adrianosmond
Copy link

No description provided.

@replete
Copy link

replete commented May 23, 2015

I'm having the same issue. Adding an empty 'placeholder' attribute does the trick for now, but superfluous.

Feels like it should be a straightforward fix, if I find sometime next week I might investigate further.

Placeholder text 'undefined' in IE9

@kbjr
Copy link
Member

kbjr commented May 23, 2015

I'm happy to accept a PR, but I don't really have time to look into myself.

@replete
Copy link

replete commented May 23, 2015

I investigated a bit further, and made the following modification which changes behaviour like so:

  • Ignores [type=password], because shimmed placeholder text is obfuscated with the password circles
  • Ignores <textarea>, because textarea doesn't support placeholders and it wasn't checking for existance of a [placeholder] attribute.

New isValidElement function:

function isValidElement(elem) {
        var tag = (elem.nodeName || '').toLowerCase();
        return (tag !== 'textarea' && (tag === 'input' && (elem.type === 'text' || elem.type !== 'password')));
    }

I spent a little while adding logic for .getAttribute('placeholder'), but ran into problems only reading getAttribute() for valid elem. For some reason MutationEvent elem variables were coming through, and I ran into issues making the logic (x instanceof y etc) work well in IE7+.

I only need IE9 so I'll leave it as is for now.

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