Hacker News new | ask | show | jobs
by untilHellbanned 4437 days ago
I like the attempt to not require the developer to write more JS, but why didn't you just add these data attributes to "a" tags? The functionality of those tags are thrown away, e.g., the "href", and "span"s aren't semantic.
2 comments

I can't say I thought too much about it. I've used spans and divs as buttons in bootstrap, so I didn't think to restrict the attributes to only be on 'a' tags.

I guess one post hoc rationalization is that the library isn't designed to replace anchors and, where they make sense, you should just keep using them.

But I'm just making that up. ;)

So along those lines, you could make it work with existing attributes. A blank `ic-src` could check for an `href` attribute on an element. An `ic-post-to` and friends could look for a parent form and grab the `action` attribute.

All in all, I think it's a neat idea. Since you give Rails examples, it might be nice to include some Rails helpers as separate project/gem that make it so you don't need to write so much boiler plate in your views.

This is also what I was thinking. By embedding the PVC metadata in the link you get fallbacks for free if the server is capable of rendering everything when the link is actually requested instead of intercepted by the framework.

I would certainly be interested in a project that does this but embeds all functionality in hyperlinks.