Skip to content

Commit 965d171

Browse files
committed
Remove useless and problematic setPrototypeOf
1 parent c9055b6 commit 965d171

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

lib/application.js

-2
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@ app.defaultConfiguration = function defaultConfiguration() {
148148
}
149149

150150
// inherit protos
151-
setPrototypeOf(this.request, parent.request)
152-
setPrototypeOf(this.response, parent.response)
153151
setPrototypeOf(this.engines, parent.engines)
154152
setPrototypeOf(this.settings, parent.settings)
155153
});

test/app.response.js

+23
Original file line numberDiff line numberDiff line change
@@ -139,5 +139,28 @@ describe('app', function(){
139139
.get('/sub/foo')
140140
.expect(200, 'FOO', cb)
141141
})
142+
143+
it('should inherit parent app', function (done) {
144+
var app1 = express()
145+
var app2 = express()
146+
var cb = after(1, done)
147+
148+
app2.request.foo = 'bar';
149+
app1.response.shout = function (str) {
150+
this.setHeader('foo', this.req.foo)
151+
this.send(str.toUpperCase())
152+
}
153+
154+
app1.use('/sub', app2)
155+
156+
app2.get('/', function (req, res) {
157+
res.shout('foo')
158+
})
159+
160+
request(app1)
161+
.get('/sub')
162+
.expect('foo', 'bar')
163+
.expect(200, 'FOO', cb)
164+
})
142165
})
143166
})

0 commit comments

Comments
 (0)