sprucemedia / jQuery.divPlaceholder.js

A mostly-CSS-with-a-bit-of-jQuery plugin to emulate the placeholder attribute for contenteditable divs.
32 stars 4 forks source link

poor performance for * selector #8

Open yairEO opened 10 years ago

yairEO commented 10 years ago

in your JS code, you are using an event-delegation such as:

*[data-placeholder]

this is a serious mistake and should be avoid at all costs to use such a poor-performance selector and listen for a lot of events for the whole document..this is insanely expensive!

CraigStuntz commented 10 years ago

On a contemporary browser, you can get by with no JavaScript whatsoever, using the :focused and :empty selectors in CSS. But I no longer work for Spruce, so I can't update it here. A good solution for new browsers is to use feature detection and pure CSS when supported, and to use ID selectors for specific elements in your page for old browsers.

yairEO commented 10 years ago

I've tried it with CSS only and this fails to work. please show me a test page where it should work, and I will show you, how it breaks in a common situation.

nathanpalmer commented 10 years ago

@CraigStuntz you actually have access to this repo now. For some reason I only partially updated it before.