Skip to content

Commit

Permalink
fix(common): Proxy function toString does not contain Proxy.
Browse files Browse the repository at this point in the history
Recent change (https://www.chromestatus.com/feature/5666372071718912) means Proxied functions
no longer throw TypeError.  Change the test to conform to the new reality.
  • Loading branch information
johnjbarton committed Mar 9, 2018
1 parent d1effbf commit 4fb3484
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions common/stringify.js
Expand Up @@ -25,8 +25,8 @@ var stringify = function stringify (obj, depth) {
return obj.toString().replace(/\{[\s\S]*\}/, '{ ... }')
} catch (err) {
if (err instanceof TypeError) {
// Proxy(function abc(...) { ... })
return 'Proxy(function ' + (obj.name || '') + '(...) { ... })'
// Support older browsers
return 'function ' + (obj.name || '') + '() { ... }'
} else {
throw err
}
Expand Down
5 changes: 1 addition & 4 deletions test/client/stringify.spec.js
Expand Up @@ -40,11 +40,8 @@ describe('stringify', function () {
// http://caniuse.com/#feat=proxy
if (window.Proxy) {
it('should serialize proxied functions', function () {
var abcProxy = new Proxy(function abc (a, b, c) { return 'whatever' }, {})
var defProxy = new Proxy(function (d, e, f) { return 'whatever' }, {})

assert.deepEqual(stringify(abcProxy), 'Proxy(function abc(...) { ... })')
assert.deepEqual(stringify(defProxy), 'Proxy(function (...) { ... })')
assert.deepEqual(stringify(defProxy), 'function () { ... }')
})
}

Expand Down

0 comments on commit 4fb3484

Please sign in to comment.