Here is a new plugin for JS API #69

Merged
merged 2 commits into from May 31, 2012

Projects

None yet

2 participants

@DmitryBaranovskiy

Known limitations: doesn’t catch onwebkitsomething changes, because I don’t know how to detect their presence.

@LeaVerou

Why not simply self.Prefix.toLowerCase()? The rest is lowercased anyway, so no reason for splitting.

Could it be “WebKit” or something? Are you 100% sure it can’t?

Owner

Yes. Look at the way it’s generated.

@LeaVerou

Wouldn’t it be better to check in a case-insensitive manner? Like, have a cached regex var prefixRegex = RegExp(prefix, 'i') and use name.search(prefixRegex)? Some DOM properties use proper camelcasing, i.e. start with an uppercase letter.

Good point.

@LeaVerou

An entire copyright notice about Adobe and no mention of your name as the author of this code? I’m not sure of the legal obligations you have as an Adobe employee, but it doesn't seem reasonable that you can't at least include your name.

I could add one line comment re my name, but because I was working on this in my company’s time I have to include this notice.

Owner

Yeah, the notice is fine, but please include your name too.

@LeaVerou

Don’t we have to take care of camelcasing too? In my tests (for transitionend) capitalization seemed to matter (i.e. the event didn't fire if the capitalization wasn’t right). Also, are we sure there's no case where both prefixed and unprefixed versions are supported? That would be catastrophic.

I don’t think it is possible to detect. if user write transitionend then I maximum script can do is to prepend it with prefix.

Events are tricky, if you insist we can drop it altogether unless there is a method to determine which prefixed events are supported ATM.

Owner

I mean, instead of just prefix + name, to also uppercase the first character of name.

Sorry, was away at the conference. There is a problem: webkitTransitionend and webkitTransitionEnd are different, but there is no way I could construct webkitTransitionEnd from webkit and transitionend, unless I carry on a vocabulary.

The question is: what is better partial support or no support?

@LeaVerou

It would be nice if the code was a bit better commented. I.e. I have no idea what this function does before reading the source.

Edit: Or even after reading it.

It digs through the objects in order to find out which have prefixed methods and therefore, which need to be extended.

Owner

Ok, that would be nice as a comment :P

@LeaVerou
Owner

Hey Dmitry,

Thank you very much for the contribution. This is great work, something like this was really needed! I added some comments in the source, could you please reply there?

Cheers

@DmitryBaranovskiy

Here are all the changes except for the events. Not sure how to tame them.

@LeaVerou
Owner

In any case, this is an additional plugin, so I'm merging this, as people might need it. Then, you can send future pull requests for the other issues.

You should also add a reference to the plugin in the project's page.

@LeaVerou LeaVerou merged commit cc49742 into LeaVerou:gh-pages May 31, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment