Permalink
Browse files

added comments, use regexp for searching

  • Loading branch information...
1 parent ff895ac commit ac32ceaf6653a75db4426aeba4218bcd4a5a2d81 @DmitryBaranovskiy DmitryBaranovskiy committed May 31, 2012
Showing with 8 additions and 4 deletions.
  1. +8 −4 plugins/prefixfree.jsapi.js
@@ -21,15 +21,18 @@
*
*/
+ /* Author Dmitry Baranovskiy */
+
(function (self) {
- var prefix = self.Prefix.charAt().toLowerCase() + self.Prefix.substring(1);
+ var prefix = self.Prefix.toLowerCase(),
+ prefixrg = new RegExp("^" + prefix, "i");
function extend(ob) {
- for(var name in ob) {
- if (!name.indexOf(prefix)) {
+ for (var name in ob) {
+ if (~name.search(prefixrg)) {
ob[name.charAt(prefix.length).toLowerCase() + name.substring(prefix.length + 1)] = ob[name];
}
}
- if(ob.addEventListener) {
+ if (ob.addEventListener) {
(function (add, remove) {
ob.addEventListener = function (name, handler, bubble) {
add.call(this, name, handler, bubble);
@@ -43,6 +46,7 @@
}
}
+ // This function digs through the objects in order to find out which have prefixed methods and therefore, which need to be extended.
function dig(o, namerg) {
var os = [],
out;

0 comments on commit ac32cea

Please sign in to comment.