mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Remove node.js specific version of Base.isPlainObject(), since straps.js can handle it now.
This commit is contained in:
parent
8aec04702c
commit
fef22f25e8
2 changed files with 8 additions and 19 deletions
|
@ -309,10 +309,12 @@ var Base = new function() {
|
|||
* plain Base object, as produced by Base.merge().
|
||||
*/
|
||||
isPlainObject: function(obj) {
|
||||
var proto = obj !== null && typeof obj === 'object'
|
||||
&& Object.getPrototypeOf(obj);
|
||||
return proto && (proto === Object.prototype
|
||||
|| proto === Base.prototype);
|
||||
var ctor = obj != null && obj.constructor;
|
||||
// We also need to check for ctor.name === 'Object', in case
|
||||
// this is an object from another global scope (e.g. an iframe,
|
||||
// or another vm context in node.js).
|
||||
return ctor && (ctor === Object || ctor === Base
|
||||
|| ctor.name === 'Object');
|
||||
},
|
||||
|
||||
check: function(obj) {
|
||||
|
|
|
@ -32,8 +32,8 @@ var options = {
|
|||
var doc = jsdom.jsdom("<html><body></body></html>"),
|
||||
win = doc.createWindow();
|
||||
|
||||
// Define XMLSerializer.
|
||||
// TODO: Put this into a simple node module, with dependency on jsdom
|
||||
// Define XMLSerializer and DOMParser shims, to emulate browser behavior.
|
||||
// TODO: Put this into a simple node module, with dependency on jsdom?
|
||||
function XMLSerializer() {
|
||||
}
|
||||
|
||||
|
@ -89,19 +89,6 @@ var context = vm.createContext({
|
|||
// Load Paper.js library files:
|
||||
context.include('paper.js');
|
||||
|
||||
// Since the context used for Paper.js compilation, and the context in which
|
||||
// Node.js scripts are executed do not share the definition of Object, we need
|
||||
// to redefine Base.isPlainObject() here.
|
||||
// So instead of checking for Object.prototype, we're checking
|
||||
// proto.constructor.name for 'Object'
|
||||
var Base = context.Base;
|
||||
Base.isPlainObject = function(obj) {
|
||||
var proto = obj !== null && typeof obj === 'object'
|
||||
&& Object.getPrototypeOf(obj);
|
||||
return proto && (proto.constructor.name === 'Object'
|
||||
|| proto === Base.prototype);
|
||||
};
|
||||
|
||||
context.PaperScope.inject({
|
||||
// Expose the Canvas, XMLSerializer & DOMParser to PaperScope:
|
||||
Canvas: Canvas,
|
||||
|
|
Loading…
Reference in a new issue