[whatwg] Proposal: Adding methods like getElementById and getElementsByTagName to DocumentFragments
Glenn Maynard
glenn at zewt.org
Thu Oct 10 07:15:13 PDT 2013
On Thu, Oct 10, 2013 at 6:06 AM, Simon Pieters <simonp at opera.com> wrote:
> $('li[id = ' + textId + ']', $slideshow3485780.context)
> $('[n_id='+allN_id+'] .notificationContainer a span')
> $('.recommend > .bd.b_con ul[city="'+city1+'"]')
>
> (The above is just a small subset of some interesting cases.)
>
> I didn't see a single case that actually used an escaping utility.
When I'm doing this I just make sure that the strings don't need escaping
in the first place. Many of these look like they do that (probably most
"ID" cases are things like random numbers or alphanumerics).
FWIW, I rarely use IDs at all: I use classes, even if there will probably
only be one of something. (Once templates enter the picture, IDs don't
make sense, so I generally just avoid them.)
On Thu, Oct 10, 2013 at 8:41 AM, Glenn Adams <glenn at skynav.com> wrote:
> Given the existence of Window.escape(), i.e., the JS escape(string)
> function property of the Global object, I wonder if choosing a longer,
> different name would be better to avoid confusion.
>
I think the "CSS" scope makes it perfectly clear and unambiguous.
--
Glenn Maynard
More information about the whatwg
mailing list