Permalink
Browse files

Added `Array.isArray()` for runtime.js as well

  • Loading branch information...
1 parent dff55a5 commit bb41b26687f724d8fb2118b42d05d7652e7c1cf2 @tj tj committed Aug 26, 2011
Showing with 9 additions and 3 deletions.
  1. +9 −3 runtime.js
View
@@ -6,6 +6,12 @@ var jade = (function(exports){
* MIT Licensed
*/
+if (!Array.isArray) {
+ Array.isArray = function(arr){
+ return '[object Array]' == toString.call(arr);
+ }
+}
+
if (!Object.keys) {
Object.keys = function(obj){
var arr = [];
@@ -44,9 +50,9 @@ exports.attrs = function attrs(obj){
: buf.push(key + '="' + key + '"');
}
} else if ('class' == key && Array.isArray(val)) {
- buf.push(key + '="' + escape(val.join(' ')) + '"');
+ buf.push(key + '="' + exports.escape(val.join(' ')) + '"');
} else {
- buf.push(key + '="' + escape(val) + '"');
+ buf.push(key + '="' + exports.escape(val) + '"');
}
}
}
@@ -61,7 +67,7 @@ exports.attrs = function attrs(obj){
* @api private
*/
-exports.escape = function escape(html){
+exports.escape = function(html){
return String(html)
.replace(/&(?!\w+;)/g, '&')
.replace(/</g, '&lt;')

0 comments on commit bb41b26

Please sign in to comment.