mirror of
https://github.com/flynx/object.js.git
synced 2025-10-29 18:40:08 +00:00
bugfix...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
5817270787
commit
a304b7d91f
13
object.js
13
object.js
@ -268,19 +268,28 @@ function(base, obj, non_strict){
|
|||||||
|
|
||||||
// like Object.create(..) but also handles callable objects correctly...
|
// like Object.create(..) but also handles callable objects correctly...
|
||||||
//
|
//
|
||||||
|
// XXX add ability to name the resulting function...
|
||||||
var create =
|
var create =
|
||||||
module.create =
|
module.create =
|
||||||
function(obj){
|
function(obj){
|
||||||
|
// name given...
|
||||||
|
if(typeof(obj) == 'string' && arguments.length > 1){
|
||||||
|
var name
|
||||||
|
;[name, obj] = arguments }
|
||||||
// calable...
|
// calable...
|
||||||
if(typeof(obj) == 'function'){
|
if(typeof(obj) == 'function'){
|
||||||
var func = function(){
|
var func = function(){
|
||||||
return Object.hasOwnProperty.call(func, '__call__') ?
|
return '__call__' in func ?
|
||||||
func.__call__.call(func, ...arguments)
|
func.__call__(this, ...arguments)
|
||||||
: 'call' in obj ?
|
: 'call' in obj ?
|
||||||
obj.call(func, ...arguments)
|
obj.call(func, ...arguments)
|
||||||
// NOTE: if obj does not inherit from Function .call
|
// NOTE: if obj does not inherit from Function .call
|
||||||
// might not be available...
|
// might not be available...
|
||||||
: Function.prototype.call.call(obj, func, ...arguments) }
|
: Function.prototype.call.call(obj, func, ...arguments) }
|
||||||
|
|
||||||
|
// XXX set the name....
|
||||||
|
// XXX
|
||||||
|
|
||||||
func.__proto__ = obj
|
func.__proto__ = obj
|
||||||
// XXX not sure about this yet...
|
// XXX not sure about this yet...
|
||||||
Object.defineProperty(func, 'toString', {
|
Object.defineProperty(func, 'toString', {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ig-object",
|
"name": "ig-object",
|
||||||
"version": "5.5.0",
|
"version": "5.5.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "object.js",
|
"main": "object.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user