LRDesign / NinjaScript

Javascript so unobtrusive, no one sees it coming.
26 stars 1 forks source link

Watermark should be renamed 'placeholder' to match HTML5 attribute #1

Closed veganstraightedge closed 13 years ago

veganstraightedge commented 13 years ago

An input with an attribute of placeholder="whatever" will Do The Right Thing™ in modern browsers worth a damn. NinjaScript should respect that and let the browser do its thing when it can.

For older browsers that don't support the placeholder attribute, NinjaScript should do its jam like Watermark currently does.

With regards to detecting placeholder browser support, Mark Pilgrim supplies this code on the Dive Into HTML5 site. http://diveintohtml5.org/detect.html

function supports_input_placeholder() { var i = document.createElement('input'); return 'placeholder' in i; }

Also, placeholder/watermark should not be used in place of a label. Nor should it stomp on the label. Maybe if there is no placeholder attribute, but there is a label, then watermark/placeholder could use the label's text as the ghosted text in the input.

nyarly commented 13 years ago

It sounds too me that this should in fact be two behaviors: modernizePlaceholders (if your browser doesn't do placeholders, we fake it) and useLabelAsPlaceholder - since the intention is that in the degraded environment, labels still be available. Keep in mind that Either or both are applied explicitly - we don't force the application just because you include NinjaScript.

nyarly commented 13 years ago

hasPlaceholder now accomplishes all of this.