Skip to content
Myr

Merge branch 'node-0.1.30'

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by visionmedia · committed by visionmedia · parents 91805f7, 0cb8d12 · Browse files · 22 files+181 added−388 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

22 files+181 added−388 removed

  • tests:+9 added−109 removed
  • other:+172 added−279 removed

22 files+181 added−388 removed

modified:examples/chat/app.js-2 removed
modified:examples/upload/app.js+3 added-3 removed
modified:lib/express/plugins/common-logger.js+1 added-1 removed
modified:lib/express/plugins/view.js+8 added-4 removed
3 unmodified lines
4/**5 * Module dependencies.6 */78var posix = require('posix'),9 utils = require('express/utils')8var utils = require('express/utils'),9 fs = require('fs')1011/**12 * Supported template engines.13 */
48 unmodified lines
62 * @api public63 */6465 render: function(view, options) {66 67 var sys= require('sys');68 69 var self = this,70 options = options || {},71 path = set('views') + '/' + view,72 type = path.split('.').slice(-2)[0],
3 unmodified lines
76 self.contentType(ext)77 function render(content) {78 content = engine[type].render(content, options)79 if (layout)77 self.render(layout + '.' + type + '.' + ext, process.mixin(true, options, {80 self.render(layout + '.' + type + '.' + ext, utils.mixin(true, options, {81 layout: false,82 locals: {83 body: content84 }
3 unmodified lines
88 }89 if (set('cache view contents') && self.cache.get(path))90 render(self.cache.get(path))91 else89 posix.cat(path).addCallback(function(content){92 fs.readFile(path, function(e, content){93 if (e) throw e94 set('cache view contents') ?95 render(self.cache.set(path, content)) :96 render(content)97 })
6 unmodified lines
modified:lib/express/spec/mocks.js+3 added-3 removed
43 unmodified lines
44 /**45 * Store _code_ and _headers_.46 */47 48 sendHeader: function(code, headers) {48 writeHeader: function(code, headers) {49 this.status = code50 this.headers = headers51 },52 53 /**54 * Store _body_.55 */56 57 sendBody: function(body) {57 write: function(body) {58 this.body = body59 },60 61 /**62 * Flag response as finished.63 */64 65 finish: function() {65 close: function() {66 this.finished = true67 }68})69
60 unmodified lines
modified:lib/express/collection.js+8 added-2 removed
12// Express - Collection - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)34/**5 * Module dependencies.6 */7 8var utils = require('express/utils')910/**11 * Throw $break in order to stop iteration.12 */1314$break = '__break__'
482 unmodified lines
497 array.push(val)498 return array499 }))500 else495 return $(process.mixin(this.arr, $(other).arr))501 return $(utils.mixin(this.arr, $(other).arr))502 },503 504 /**505 * Clone the collection.
2 unmodified lines
508 * @api public509 */510 511 clone: function() {506 return this.merge({})512 return $(utils.clone(this.arr))513 },514 515 /**516 * Return the value of a random index.
33 unmodified lines
modified:lib/express/core.js+51 added-51 removed
12// Express - Core - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)34process.mixin(require('sys'))5process.mixin(require('express/exceptions'))6process.mixin(require('express/collection'))7process.mixin(require('express/event'))8process.mixin(require('express/request'))9process.mixin(require('express/plugin'))10process.mixin(require('express/dsl'))114/**5 * Module dependencies.6 */78var multipart = require('multipart'),9 utils = require('express/utils'),10 events = require('events'),18 File = require('file').File,19 utils = require('express/utils')20 11 fs = require('fs')1213utils.mixin(require('sys'))14utils.mixin(require('express/exceptions'))15utils.mixin(require('express/collection'))16utils.mixin(require('express/event'))17utils.mixin(require('express/request'))18utils.mixin(require('express/plugin'))19utils.mixin(require('express/dsl'))2021// --- Route2223Route = Class({24
183 unmodified lines
208 require('http')209 .createServer(function(request, response){210 request.body = ''211 request.setBodyEncoding('binary')212 var callback= function(error, result) {213 if(error) { // THIS is the same code as in the 'route' code, needs refactoring214 if (request.accepts('html') && set('show exceptions'))215 request.halt(500, require('express/pages/show-exceptions').render(request, error))216 else217 request.halt(500)218 if (set('throw exceptions'))219 throw error220 } 221 else self.route(request, response); 222 };223 if (request.headers['content-type'] &&224 request.headers['content-type'].indexOf('multipart/form-data') !== -1) {214 var stream = new multipart.Stream(request),215 promise = new events.Promise,216 pendingFiles = 0217 request.params = { post: {}}218 promise.timeout(set('upload timeout') || 5000)219 stream.addListener('part', function(part){220 if (part.filename) {221 var file = new File(part.tempfile = '/tmp/express-' + Number(new Date) + utils.uid(), 'w', { encoding: 'binary' })222 ++pendingFiles223 part.pos = 0224 part.addListener('body', function(chunk){225 file.write(chunk, part.pos, 'binary').addErrback(function(){226 promise.emitError.apply(promise, arguments)227 })228 part.pos += chunk.length229 })230 .addListener('complete', function(){231 file.close().addCallback(function(){232 if (!--pendingFiles)233 promise.emitSuccess()234 }).addErrback(function(){235 promise.emitError.apply(promise, arguments)236 })237 utils.mergeParam(part.name, part, request.params.post)238 })239 }240 else241 part.buf = '',242 part243 .addListener('body', function(chunk){ part.buf += chunk })244 .addListener('complete', function(){245 if (part.buf.length)246 utils.mergeParam(part.name, part.buf, request.params.post)247 })248 }).addListener('complete', function(){249 if (!pendingFiles) promise.emitSuccess()250 promise.addCallback(function(){ self.route(request, response) })251 })225 var mp= multipart.parse(request);226 request.params= { post: {}};227 mp.addListener("partBegin", function (part) { 228 if( part.filename ) {229 part.tempfile= '/tmp/express-' + Number(new Date) + utils.uid(); 230 part.fileStream= fs.createWriteStream( part.tempfile ); 231 }232 else part.buf= '';233 });234 mp.addListener("partEnd", function (part) { 235 if( part.name ) { // Not sure why this guard is needed, but otherwise we get an undefined part.name being passed?236 if( part.fileStream ) { 237 part.fileStream.close(); 238 utils.mergeParam(part.name, {filename:part.filename, tempfile:part.tempfile}, request.params.post) 239 }240 else {241 utils.mergeParam(part.name, part.buf, request.params.post) 242 }243 }244 });245 246 mp.addListener("body", function (chunk) {247 if( mp.part.fileStream ) mp.part.fileStream.write(chunk) ;248 else part.buf+= chunk;249 });250 mp.addListener("error", callback); 251 mp.addListener("complete", callback);252 }253 else254 request255 .addListener('body', function(chunk){ request.body += chunk })256 .addListener('complete', function(){ self.route(request, response) })255 .addListener('data', function(chunk){ request.body += chunk })256 .addListener('end', callback )257 })258 .listen(this.port, this.host, this.backlog)259 puts('Express started at http://' + this.host + ':' + this.port + '/ in ' + Express.environment + ' mode')260 },
63 unmodified lines
deleted:lib/express/element-collection.js-179 removed
12// Express - ElementCollection - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)34/**5 * Module dependencies.6 */78var libxml = require('libxmljs')910// --- css2xpath1112/** version 0.1 2009-04-3013 * @author Andrea Giammarchi14 * @license Mit Style License15 * @project http://code.google.com/p/css2xpath/16 */17var css2xpath=(function(){var b=[/\[([^\]~\$\*\^\|\!]+)(=[^\]]+)?\]/g,"[@$1$2]",/\s*,\s*/g,"|",/\s*(\+|~|>)\s*/g,"$1",/([a-zA-Z0-9\_\-\*])~([a-zA-Z0-9\_\-\*])/g,"$1/following-sibling::$2",/([a-zA-Z0-9\_\-\*])\+([a-zA-Z0-9\_\-\*])/g,"$1/following-sibling::*[1]/self::$2",/([a-zA-Z0-9\_\-\*])>([a-zA-Z0-9\_\-\*])/g,"$1/$2",/\[([^=]+)=([^'|"][^\]]*)\]/g,"[$1='$2']",/(^|[^a-zA-Z0-9\_\-\*])(#|\.)([a-zA-Z0-9\_\-]+)/g,"$1*$2$3",/([\>\+\|\~\,\s])([a-zA-Z\*]+)/g,"$1//$2",/\s+\/\//g,"//",/([a-zA-Z0-9\_\-\*]+):first-child/g,"*[1]/self::$1",/([a-zA-Z0-9\_\-\*]+):last-child/g,"$1[not(following-sibling::*)]",/([a-zA-Z0-9\_\-\*]+):only-child/g,"*[last()=1]/self::$1",/([a-zA-Z0-9\_\-\*]+):empty/g,"$1[not(*) and not(normalize-space())]",/([a-zA-Z0-9\_\-\*]+):not\(([^\)]*)\)/g,function(f,e,d){return e.concat("[not(",a(d).replace(/^[^\[]+\[([^\]]*)\].*$/g,"$1"),")]")},/([a-zA-Z0-9\_\-\*]+):nth-child\(([^\)]*)\)/g,function(f,e,d){switch(d){case"n":return e;case"even":return"*[position() mod 2=0 and position()>=0]/self::"+e;case"odd":return e+"[(count(preceding-sibling::*) + 1) mod 2=1]";default:d=(d||"0").replace(/^([0-9]*)n.*?([0-9]*)$/,"$1+$2").split("+");d[1]=d[1]||"0";return"*[(position()-".concat(d[1],") mod ",d[0],"=0 and position()>=",d[1],"]/self::",e)}},/:contains\(([^\)]*)\)/g,function(e,d){return"[contains(string(.),'"+d+"')]"},/\[([a-zA-Z0-9\_\-]+)\|=([^\]]+)\]/g,"[@$1=$2 or starts-with(@$1,concat($2,'-'))]",/\[([a-zA-Z0-9\_\-]+)\*=([^\]]+)\]/g,"[contains(@$1,$2)]",/\[([a-zA-Z0-9\_\-]+)~=([^\]]+)\]/g,"[contains(concat(' ',normalize-space(@$1),' '),concat(' ',$2,' '))]",/\[([a-zA-Z0-9\_\-]+)\^=([^\]]+)\]/g,"[starts-with(@$1,$2)]",/\[([a-zA-Z0-9\_\-]+)\$=([^\]]+)\]/g,function(f,e,d){return"[substring(@".concat(e,",string-length(@",e,")-",d.length-3,")=",d,"]")},/\[([a-zA-Z0-9\_\-]+)\!=([^\]]+)\]/g,"[not(@$1) or @$1!=$2]",/#([a-zA-Z0-9\_\-]+)/g,"[@id='$1']",/\.([a-zA-Z0-9\_\-]+)/g,"[contains(concat(' ',normalize-space(@class),' '),' $1 ')]",/\]\[([^\]]+)/g," and ($1)"],c=b.length;return function a(e){var d=0;while(d<c){e=e.replace(b[d++],b[d++])}return"//"+e}})();1819// --- ElementCollection2021ElementCollection = Collection.extend({22 23 /**24 * Initialize with string of _markup_.25 *26 * @param {string} markup27 * @api private28 */29 30 init: function(markup) {31 if (typeof markup != 'string')32 return this.__super__(markup)33 if (!(/<html>/.test(markup))) 34 markup = '<html><body>' + markup + '</body></html>'35 this.document = libxml.parseHtmlString(markup)36 this.arr = [this.document.root()]37 },38 39 /**40 * Return the first element's name.41 *42 * @return {string}43 * @api public44 */45 46 name: function() {47 return this.at(0).name()48 },49 50 /**51 * Search child elements with the given _xpath_.52 *53 * @param {string} xpath54 * @return {ElementCollection}55 * @api public56 */57 58 xpath: function(xpath) {59 // TODO: refactor with flatten()60 return $(this.reduce([], function(array, e){61 $(e.find(xpath)).each(function(child){62 array.push(child)63 })64 return array65 }))66 },67 68 /**69 * Search child elements with the given css _selector_70 *71 * @param {string} selector72 * @return {ElementCollection}73 * @api public74 */75 76 search: function(selector) {77 return this.xpath(css2xpath(selector))78 },79 80 /**81 * Return collection of children.82 *83 * @return {ElementCollection}84 * @api public85 */86 87 children: function() {88 // TODO: refactor with flatten()89 return $(this.reduce([], function(array, e){90 $(e.children()).each(function(child){91 array.push(child)92 })93 return array94 }))95 },96 97 /**98 * Return collection of parents.99 *100 * @return {ElementCollection}101 * @api public102 */103 104 parents: function() {105 return this.map(function(e){106 return e.parent()107 })108 },109 110 /**111 * Return the first element's parent.112 *113 * @return {ElementCollection}114 * @api public115 */116 117 parent: function() {118 return $([this.at(0).parent()])119 },120 121 /**122 * Return the prev element.123 *124 * @return {ElementCollection}125 * @api public126 */127 128 prev: function() {129 return $([this.at(0).prevSibling()])130 },131 132 /**133 * Return the next element.134 *135 * @return {ElementCollection}136 * @api public137 */138 139 next: function() {140 return $([this.at(0).nextSibling()])141 },142 143 /**144 * Return the first element's text content.145 *146 * @return {string}147 * @api public148 */149 150 text: function() {151 return this.at(0).text()152 },153 154 /**155 * Convert collection to a string.156 *157 * @return {string}158 * @api public159 */160 161 toString: function() {162 if (this.at(0) && this.at(0).doc)163 return '[Collection <elements>]'164 return this.__super__()165 }166})167168/**169 * Add markup support to $().170 *171 * @param {object} arr172 * @return {Collection, ElementCollection}173 * @api public174 */175 176var $ = exports.$ = function(arr) {177 if (arr instanceof Collection) return arr178 return new ElementCollection(arr)179}
modified:lib/express/event.js-1 removed
12// Express - Event - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)33exports.Event = Class({4 5 /**6 * Initialize with event _name_ and optional _data_.
22 unmodified lines
modified:lib/express/http.js+2 added-2 removed
36 unmodified lines
37 headers['content-length'] = data.length38 headers['content-type'] = 'application/x-www-form-urlencoded'39 }40 var request = client.request(method, path + search + hash, headers)41 if (data) request.sendBody(data)42 request.finish(function(response){41 if (data) request.write(data)42 request.close(function(response){43 if (response.statusCode < 200 || response.statusCode >= 400)44 promise.emitError(new Error('request failed with status ' + response.statusCode + ' "' + http.STATUS_CODES[response.statusCode] + '"'))45 else if (response.statusCode >= 300 && response.statusCode < 400)46 request(method, response.headers.location, headers, data, promise)
33 unmodified lines
modified:lib/express/plugin.js+2 added-2 removed
11var utils = require('express/utils');2// Express - Plugin - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)34/**5 * Push _plugin_ with _options_ to the plugin stack.
30 unmodified lines
36 */37 38 init: function(options) {39 if (options)40 process.mixin(this, options)40 utils.mixin(this, options)41 },42 43 /**44 * Trigger handler for the given _event_.
11 unmodified lines
modified:lib/express/plugins.js+10 added-10 removed
12// Express - Plugins - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)34process.mixin(require('express/plugins/hooks'))5process.mixin(require('express/plugins/flash'))6process.mixin(require('express/plugins/cache'))7process.mixin(require('express/plugins/cookie'))8process.mixin(require('express/plugins/session'))9process.mixin(require('express/plugins/profiler'))10process.mixin(require('express/plugins/common-logger'))11process.mixin(require('express/plugins/content-length'))12process.mixin(require('express/plugins/method-override'))3var utils = require('express/utils');4utils.mixin(require('express/plugins/hooks'))5utils.mixin(require('express/plugins/flash'))6utils.mixin(require('express/plugins/cache'))7utils.mixin(require('express/plugins/cookie'))8utils.mixin(require('express/plugins/session'))9utils.mixin(require('express/plugins/profiler'))10utils.mixin(require('express/plugins/common-logger'))11utils.mixin(require('express/plugins/content-length'))12utils.mixin(require('express/plugins/method-override'))
modified:lib/express/request.js+5 added-4 removed
7 unmodified lines
8var StaticFile = require('express/static').File,9 statusBodies = require('http').STATUS_CODES,10 queryString = require('querystring'),11 mime = require('express/mime'),12 utils= require('express/utils'),13 url = require('url')1415// --- InvalidStatusCode16
46 unmodified lines
63 * @api private64 */65 66 init: function(request, response) {66 process.mixin(true, this, request)67 utils.mixin(true, this, request)68 response.headers = {}69 this.response = response70 this.url = url.parse(this.url)71 this.url.pathname = exports.normalizePath(this.url.pathname)
119 unmodified lines
191 this.response.body = body192 this.trigger('response')193 if (typeof this.response.body != 'string') throw new InvalidResponseBody(this)194 if (typeof this.response.status != 'number') throw new InvalidStatusCode(this.response.status)194 this.response.sendHeader(this.response.status, this.response.headers)195 this.response.sendBody(this.response.body, encoding)196 this.response.finish()195 this.response.writeHeader(this.response.status, this.response.headers)196 this.response.write(this.response.body, encoding)197 this.response.close()198 },199 200 /**201 * Set Content-Type header to the mime type
74 unmodified lines
modified:lib/express/static.js+5 added-3 removed
12// Express - Static - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)34var path = require('path'),5 posix = require('posix')5 fs = require('fs')6 7// --- InvalidPathError89InvalidPathError = ExpressError.extend({
38 unmodified lines
48 return request.contentType(cache.type),49 request.halt(200, cache.content, 'binary')50 path.exists(file, function(exists){51 if (!exists) return request.halt()52 posix.stat(file).addCallback(function(stats){52 fs.stat(file, function(e, stats){53 if (e) throw e54 if (!stats.isFile()) return request.halt()54 posix.cat(file, 'binary').addCallback(function(content){55 fs.readFile(file, 'binary', function(e, content){56 if (e) throw e57 request.contentType(file)58 if (set('cache static files'))59 request.cache.set(file, { type: file, content: content })60 request.halt(200, content, 'binary')
5 unmodified lines
modified:lib/express/utils.js+76 added-1 removed
129 unmodified lines
130 params = params[key]131 return parts[key]132 })133 return orig134}134}135136/**137 * Return a clone of _obj_.138 *139 * @param {mixed} obj140 * @return {mixed}141 * @api public142 */143144function Clone() {}145exports.clone = function(obj) {146 Clone.prototype = obj147 return new Clone148}149150// From jQuery.extend in the jQuery JavaScript Library v1.3.2151// Copyright (c) 2009 John Resig152// Dual licensed under the MIT and GPL licenses.153// http://docs.jquery.com/License154// Modified for node.js (formely for copying properties correctly)155exports.mixin = function() {156 // copy reference to target object157 var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, source;158159 // Handle a deep copy situation160 if ( typeof target === "boolean" ) {161 deep = target;162 target = arguments[1] || {};163 // skip the boolean and the target164 i = 2;165 }166167 // Handle case when target is a string or something (possible in deep copy)168 if ( typeof target !== "object" && !(typeof target === 'function') )169 target = {};170171 // mixin process itself if only one argument is passed172 if ( length == i ) {173 target = GLOBAL;174 --i;175 }176177 for ( ; i < length; i++ ) {178 // Only deal with non-null/undefined values179 if ( (source = arguments[i]) != null ) {180 // Extend the base object181 Object.getOwnPropertyNames(source).forEach(function(k){182 var d = Object.getOwnPropertyDescriptor(source, k) || {value: source[k]};183 if (d.get) {184 target.__defineGetter__(k, d.get);185 if (d.set) {186 target.__defineSetter__(k, d.set);187 }188 }189 else {190 // Prevent never-ending loop191 if (target !== d.value) {192193 if (deep && d.value && typeof d.value === "object") {194 target[k] = exports.mixin(deep,195 // Never move original objects, clone them196 target[k] || (d.value.length != null ? [] : {})197 , d.value);198 }199 else {200 target[k] = d.value;201 }202 }203 }204 });205 }206 }207 // Return the modified object208 return target;209};
deleted:spec/support/libxmljsnot shown

Its text is not shown, deleted.

modified:spec/node.js+4 added-23 removed
12require.paths.unshift('spec', 'lib', 'spec/lib', 'spec/support/libxmljs')2require.paths.unshift('spec', 'lib', 'spec/lib')3require("jspec")4require("express")5require("express/spec")67quit = process.exit7print = puts8quit = process.exit9readFile = require('fs').readFileSync1010readFile = function(path) {11 var result12 require('posix')13 .cat(path, "utf8")14 .addCallback(function(contents){ result = contents })15 .addErrback(function(){ throw new Error("failed to read file `" + path + "'") })16 .wait()17 return result18}1911function run(specs) {12 specs.forEach(function(spec){13 JSpec.exec('spec/spec.' + spec + '.js')14 })
19 unmodified lines
34 'plugins.hooks',35 'plugins.cookie',36 'plugins.session',37 'plugins.flash',47 ],48 dependant: [49 'element-collection'50 ]38 ]39}4041switch (process.ARGV[2]) {54 case 'independant':55 run(specs.independant)56 break57 case 'dependant':58 run(specs.dependant)59 break42 case 'all':43 run(specs.independant)62 run(specs.dependant)44 break45 default: 46 run([process.ARGV[2]])47}
3 unmodified lines
modified:spec/spec.collection.js+2 added
382 unmodified lines
383 var a = $([1,2,3])384 var b = a.clone()385 a.should.not.equal b386 b.arr.should.eql [1,2,3]387 b.arr.should.not.equal a.arr388 end389 390 it 'should clone an object collection'391 var a = $({ foo: 'bar' })392 var b = a.clone()393 a.should.not.equal b394 b.arr.should.eql { foo: 'bar' }395 b.arr.should.not.equal a.arr396 end397 end398 399 describe '#sample()'
75 unmodified lines
deleted:spec/spec.element-collection.js-83 removed
12process.mixin(require('express/collection'))3process.mixin(require('express/element-collection'))45describe 'Express'6 describe 'ElementCollection'7 8 describe '$("markup string")'9 it 'should return a ElementCollection'10 $('<p>foo</p>').should.be_an_instance_of Collection11 $('<p>foo</p>').should.be_an_instance_of ElementCollection12 end13 14 it 'should wrap with <html><body>.. when not present'15 $('<p>foo</p>').at(0).name().should.eql 'html'16 end17 18 it 'should not wrap with <html><body> when already present'19 $('<html><body></body></html>').at(0).name().should.eql 'html'20 end21 end22 23 describe '#name()'24 it 'should return the first elements name'25 $('<html><body></body></html>').name().should.eql 'html'26 end27 end28 29 describe '#xpath()'30 it 'should find children matching the given xpath'31 $('<li>1</li><li>2</li>').xpath('descendant-or-self::li').length().should.eql 232 $('<li>1</li><li>2</li>').xpath('descendant-or-self::li').at(0).name().should.eql 'li'33 var items = $('<li><p>Foo</p></li><li><p>Bar</p></li>').xpath('descendant-or-self::li')34 items.xpath('descendant-or-self::p').length().should.eql 235 end36 end37 38 describe '#search()'39 it 'should find children matching the given css selector'40 $('<ul><li>foo</li><li>bar</li></ul>').search('ul > li:nth-child(2)').text().should.eql 'bar'41 end42 end43 44 describe '#children()'45 it 'should return children'46 $('<p><em>foo</em><strong>bar</strong></p>').children().length().should.eql 147 $('<p><em>foo</em><strong>bar</strong></p>').xpath('descendant-or-self::p').children().length().should.eql 248 end49 end50 51 describe '#parents()'52 it 'should return parents'53 $('<ul><li></li></ul><ul><li></li></ul>').xpath('descendant-or-self::li').parents().length().should.eql 254 $('<ul><li></li></ul><ul><li></li></ul>').xpath("descendant-or-self::*/*[name() = 'ul' and (position() = 1)]/descendant::li").parents().length().should.eql 155 end56 end57 58 describe '#parent()'59 it 'should return the first parent'60 $('<ul><li></li></ul><ul><li></li></ul>').xpath('descendant-or-self::li').parent().length().should.eql 161 end62 end63 64 describe '#text()'65 it 'should return an elements text'66 $('<p>foo bar</p>').text().should.eql 'foo bar'67 end68 end69 70 describe '#next()'71 it 'should return the next element'72 $('<em>foo</em><p>bar</p>').xpath('descendant-or-self::em').next().text().should.eql 'bar'73 end74 end75 76 describe '#prev()'77 it 'should return the previous element'78 $('<em>foo</em><p>bar</p>').xpath('descendant-or-self::p').prev().text().should.eql 'foo'79 end80 end81 82 end83end
modified:.gitmodules-3 removed
1[submodule "spec/support/libxmljs"]2 path = spec/support/libxmljs3 url = git://github.com/sprsquish/libxmljs.git1[submodule "lib/support/haml"]2 path = lib/support/haml3 url = git://github.com/creationix/haml-js.git4[submodule "lib/support/js-oo"]
5 unmodified lines
modified:Makefile+1 added-10 removed
4 unmodified lines
56init:7 @git submodule init && git submodule update89test: init spec/support/libxmljs/libxmljs.node9test: init10 @$(NODE) spec/node.js all11 12test-independant: init13 @$(NODE) spec/node.js independant14 15test-dependant: init spec/support/libxmljs/libxmljs.node16 @$(NODE) spec/node.js dependant17 12app: app-chat13 14app-chat:15 @$(NODE) examples/chat/app.js
4 unmodified lines
20benchmark:21 @$(NODE) benchmarks/collection.js22 @$(NODE) benchmarks/views.js23 30spec/support/libxmljs/libxmljs.node:31 @scons -C spec/support/libxmljs libxmljs.node32 24.PHONY: init test benchmark app
modified:Readme.md-1 removed
19 unmodified lines
20 * Test helpers (mock requests etc)21 * Environment based configuration22 * Light-weight JavaScript class implementation via js-oo23 * Collections and chainable iterators24 * ElementCollections / markup parsing via libxmljs and css selector traversal support via css2xpath24 * View support (ejs, haml, sass, etc)25 26## Installation27
112 unmodified lines