Skip to content

Instantly share code, notes, and snippets.

@michaelficarra
Created August 10, 2010 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelficarra/516654 to your computer and use it in GitHub Desktop.
Save michaelficarra/516654 to your computer and use it in GitHub Desktop.
commit 30b81beab62b14fb9bc81240cb9e91a57d9baf5e
Author: Michael Ficarra <git@michael.ficarra.me>
Date: Mon Aug 9 17:12:28 2010 -0400
don't require the *protect* instance method when we can use
Function.protect instead
diff --git a/Source/Core/Core.js b/Source/Core/Core.js
index 9eb9f68..30e0b92 100644
--- a/Source/Core/Core.js
+++ b/Source/Core/Core.js
@@ -245,11 +245,11 @@ var force = function(name, object, methods){
generic = object[key],
proto = prototype[key];
- if (generic) generic.protect();
+ if (generic) Function.protect(generic);
if (isType && proto){
delete prototype[key];
- prototype[key] = proto.protect();
+ prototype[key] = Function.protect(proto);
}
}
commit 59f06321733e6a1988b8283edc1d9f70a4f8557d
Author: Michael Ficarra <git@michael.ficarra.me>
Date: Mon Aug 9 16:24:45 2010 -0400
avoid using *override* as an identifier
diff --git a/Source/Slick/Slick.Finder.js b/Source/Slick/Slick.Finder.js
index 25de2e3..c86d414 100644
--- a/Source/Slick/Slick.Finder.js
+++ b/Source/Slick/Slick.Finder.js
@@ -190,9 +190,9 @@ local.search = function(context, expression, append, first){
// Overrides
for (i = this.overrides.length; i--;){
- var override = this.overrides[i];
- if (override.regexp.test(expression)){
- var result = override.method.call(context, expression, found, first);
+ var _override = this.overrides[i];
+ if (_override.regexp.test(expression)){
+ var result = _override.method.call(context, expression, found, first);
if (result === false) continue;
if (result === true) return found;
return result;
commit 2220ee69d82be8bef23a702f8d4a72f9ae19d95f
Author: Michael Ficarra <git@michael.ficarra.me>
Date: Mon Aug 9 16:21:03 2010 -0400
don't require that the Function global exists, but prefer its use if it
does
diff --git a/Source/Core/Core.js b/Source/Core/Core.js
index 5e54cbf..9eb9f68 100644
--- a/Source/Core/Core.js
+++ b/Source/Core/Core.js
@@ -56,7 +56,7 @@ var instanceOf = this.instanceOf = function(item, object){
// Function overloading
-var Function = this.Function;
+var Function = this.Function || (function(){}).constructor;
var enumerables = true;
for (var i in {toString: 1}) enumerables = null;
commit 7363f3ec7c88df15fc8738477a3e1255fa839cfc
Author: Michael Ficarra <git@michael.ficarra.me>
Date: Mon Aug 9 16:10:51 2010 -0400
Should try not to append to the documentElemnt itself if a body exists.
Slick attempts to append to the documentElement, which is illegal for
HTML4.0 and XHTML documents, since they can (and must) contain only a
single head element and a single body element -- nothing else is allowed.
Now, the dummy object should be appended to the body if one exists, falling
back to the old method if that is not possible. This keeps Slick as
standards- compliant as possible, while still maintaining compatibility
with non-HTML XML documents.
diff --git a/Source/Slick/Slick.Finder.js b/Source/Slick/Slick.Finder.js
index ab11a13..25de2e3 100644
--- a/Source/Slick/Slick.Finder.js
+++ b/Source/Slick/Slick.Finder.js
@@ -35,7 +35,10 @@ local.setDocument = function(document){
if (this.document === document) return;
this.document = document;
- var root = this.root = document.documentElement;
+ var root = document.documentElement;
+ var body = root.getElementsByTagName('body');
+ if(body && body.length) root = body[0];
+ this.root = root;
// document sort
commit e9f8f42a0378d630dec05731d24368e55777f8ca
Author: Michael Ficarra <git@michael.ficarra.me>
Date: Mon Aug 9 15:57:36 2010 -0400
cannot assume document.head exists except in HTML 5 documents
diff --git a/Source/Browser/Browser.js b/Source/Browser/Browser.js
index ee660d4..e631310 100644
--- a/Source/Browser/Browser.js
+++ b/Source/Browser/Browser.js
@@ -115,8 +115,11 @@ Browser.exec = function(text){
var script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.text = text;
- document.head.appendChild(script);
- document.head.removeChild(script);
+ var root = document && (document.head || document.body);
+ if(root){
+ root.appendChild(script);
+ root.removeChild(script);
+ }
}
return text;
};
commit 6aa612b5e0b3c8995cd16cdebfe8c754eb688576
Author: Michael Ficarra <git@michael.ficarra.me>
Date: Mon Aug 9 15:46:53 2010 -0400
should not assume that window.frames exists
diff --git a/Source/Element/Element.js b/Source/Element/Element.js
index 7ca8122..f83e61b 100644
--- a/Source/Element/Element.js
+++ b/Source/Element/Element.js
@@ -101,7 +101,7 @@ var IFrame = new Type('IFrame', function(){
var contentWindow = Function.attempt(function(){
return iframe.contentWindow;
});
- ((contentWindow && contentWindow.document.body) || window.frames[props.id]) ? onFrameLoad() : iframe.addListener('load', onFrameLoad);
+ ((contentWindow && contentWindow.document.body) || (window.frames && window.frames[props.id])) ? onFrameLoad() : iframe.addListener('load', onFrameLoad);
return iframe;
});
commit c479add9e600a8c76a66dfe47a7e633f015be298
Author: Michael Ficarra <git@michael.ficarra.me>
Date: Tue Aug 10 17:47:24 2010 -0400
ES5 safety: arguments.callee will not be accessible in strict mode
diff --git a/Source/Core/Core.js b/Source/Core/Core.js
index 963702a..96a9c26 100644
--- a/Source/Core/Core.js
+++ b/Source/Core/Core.js
@@ -36,8 +36,8 @@ var typeOf = this.typeOf = function(item){
if (item.nodeName){
if (item.nodeType == 1) return 'element';
if (item.nodeType == 3) return (/\S/).test(item.nodeValue) ? 'textnode' : 'whitespace';
- } else if (typeof item.length == 'number'){
- if (item.callee) return 'arguments';
+ } else if (Object.prototype.hasOwnProperty.call(item,'length') && typeof item.length == 'number'){
+ if (Object.prototype.hasOwnProperty.call(item,'callee')) return 'arguments';
if ('item' in item) return 'collection';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment