mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42:07 -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().
|
* plain Base object, as produced by Base.merge().
|
||||||
*/
|
*/
|
||||||
isPlainObject: function(obj) {
|
isPlainObject: function(obj) {
|
||||||
var proto = obj !== null && typeof obj === 'object'
|
var ctor = obj != null && obj.constructor;
|
||||||
&& Object.getPrototypeOf(obj);
|
// We also need to check for ctor.name === 'Object', in case
|
||||||
return proto && (proto === Object.prototype
|
// this is an object from another global scope (e.g. an iframe,
|
||||||
|| proto === Base.prototype);
|
// or another vm context in node.js).
|
||||||
|
return ctor && (ctor === Object || ctor === Base
|
||||||
|
|| ctor.name === 'Object');
|
||||||
},
|
},
|
||||||
|
|
||||||
check: function(obj) {
|
check: function(obj) {
|
||||||
|
|
|
@ -32,8 +32,8 @@ var options = {
|
||||||
var doc = jsdom.jsdom("<html><body></body></html>"),
|
var doc = jsdom.jsdom("<html><body></body></html>"),
|
||||||
win = doc.createWindow();
|
win = doc.createWindow();
|
||||||
|
|
||||||
// Define XMLSerializer.
|
// Define XMLSerializer and DOMParser shims, to emulate browser behavior.
|
||||||
// TODO: Put this into a simple node module, with dependency on jsdom
|
// TODO: Put this into a simple node module, with dependency on jsdom?
|
||||||
function XMLSerializer() {
|
function XMLSerializer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,19 +89,6 @@ var context = vm.createContext({
|
||||||
// Load Paper.js library files:
|
// Load Paper.js library files:
|
||||||
context.include('paper.js');
|
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({
|
context.PaperScope.inject({
|
||||||
// Expose the Canvas, XMLSerializer & DOMParser to PaperScope:
|
// Expose the Canvas, XMLSerializer & DOMParser to PaperScope:
|
||||||
Canvas: Canvas,
|
Canvas: Canvas,
|
||||||
|
|
Loading…
Reference in a new issue