superfeedr / subtome

A universal Subscribe/Follow button.
http://subtome.com
MIT License
166 stars 32 forks source link

Casing of dataset attributes blocks usage #78

Closed onli closed 10 years ago

onli commented 10 years ago

I'm trying to use the data-* attributes to hardcode the feed that is used when clicking on the button, instead of using autodetection (several in the head). My first approach was

data-subtomeFeeds="$urlencodedFeed"

That doesn't work, because Firefox 30 converts this to data-subtomefeeds, the load.js then can't find this. It's only possible to use this mechanism by setting the feeds-dataset via JS (yeah, the code is not actually nice, sorry):

onclick="document.subtomeBtn=document.querySelector('#serendipity_subtome');document.subtomeBtn.dataset['subtomeFeeds']='". urlencode($mainFeed). "';var s=document.createElement('script');s.src='https://www.subtome.com/load.js';document.body.appendChild(s);return false;";

So I have a workaround, but it feels like a bug. Also, it would be nice if the href-element was used directly, if present.

This might be browserspecific, and I might be misunderstanding how this is supposed to be used.

julien51 commented 10 years ago

@onli Thanks for the feedback, but I have to say I'm not sure I perfectly understand what the problem is?

I believe the data-url attribute are actually low case like data-subtome-feeds. Why do you use data-subtomeFeeds?

onli commented 10 years ago

@julien51 Thanks for the fast response.

Why do you use data-subtomeFeeds?

It's perfectly possible I missed the point there. In fact, I didn't find the proper documentation. I had a look at https://github.com/superfeedr/subtome/blob/d50147a36aaf06e95bb28cfd4b55cba2fe5ee4e1/app/load.js#L43 and there subtomeBtn.dataset.subtomeFeeds is read. Is data-subtome-feeds read at another place, or is there an equivalence as a a js-feature I don't know about?

julien51 commented 10 years ago

@onli that's actually the way data-* attributes work: in the HTML they're lowercase and - separated words and in JS, you access them useing the camelcase version (without the data-part). This way I believe it's consistent with HTML and JS styling guides. (And in practce they do not designated the same thing)

onli commented 10 years ago

@julien51 Ok, that would explain it. Lack of knowledge on my part, sorry. Thanks for the help.

julien51 commented 10 years ago

No, no, the lesson from this is that we should make it easier to find the docs :)