mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Switch to Bootstrap.js version that is produced by compiling it with CORE_ONLY flag, and adapt Base.js so Base still gets exported.
This commit is contained in:
parent
aade3391e5
commit
7c57324b3a
2 changed files with 28 additions and 11 deletions
30
lib/bootstrap.js
vendored
30
lib/bootstrap.js
vendored
|
@ -11,12 +11,11 @@
|
||||||
* http://prototypejs.org/
|
* http://prototypejs.org/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var Base = this.Base = new function() {
|
var Base = new function() { // Bootstrap scope
|
||||||
// Fix __proto__ for browsers where it is not implemented (IE and Opera).
|
// Fix __proto__ for browsers where it is not implemented (IE and Opera).
|
||||||
var fix = !this.__proto__,
|
var fix = !this.__proto__,
|
||||||
hidden = /^(statics|generics|preserve|beans|enumerable|prototype|__proto__|toString|valueOf)$/,
|
hidden = /^(statics|generics|preserve|enumerable|beans|prototype|__proto__|toString|valueOf)$/,
|
||||||
proto = Object.prototype,
|
proto = Object.prototype,
|
||||||
toString = proto.toString,
|
|
||||||
/**
|
/**
|
||||||
* Private function that checks if an object contains a given property.
|
* Private function that checks if an object contains a given property.
|
||||||
* Naming it 'has' causes problems on Opera when defining
|
* Naming it 'has' causes problems on Opera when defining
|
||||||
|
@ -28,6 +27,7 @@ var Base = this.Base = new function() {
|
||||||
return name !== '__proto__' && this.hasOwnProperty(name);
|
return name !== '__proto__' && this.hasOwnProperty(name);
|
||||||
}
|
}
|
||||||
: proto.hasOwnProperty,
|
: proto.hasOwnProperty,
|
||||||
|
toString = proto.toString,
|
||||||
proto = Array.prototype,
|
proto = Array.prototype,
|
||||||
isArray = Array.isArray = Array.isArray || function(obj) {
|
isArray = Array.isArray = Array.isArray || function(obj) {
|
||||||
return toString.call(obj) === '[object Array]';
|
return toString.call(obj) === '[object Array]';
|
||||||
|
@ -38,6 +38,9 @@ var Base = this.Base = new function() {
|
||||||
iter.call(bind, this[i], i, this);
|
iter.call(bind, this[i], i, this);
|
||||||
},
|
},
|
||||||
forIn = function(iter, bind) {
|
forIn = function(iter, bind) {
|
||||||
|
// Do not use Object.keys for iteration as iterators might modify
|
||||||
|
// the object we're iterating over, making the hasOwnProperty still
|
||||||
|
// necessary.
|
||||||
for (var i in this)
|
for (var i in this)
|
||||||
if (this.hasOwnProperty(i))
|
if (this.hasOwnProperty(i))
|
||||||
iter.call(bind, this[i], i, this);
|
iter.call(bind, this[i], i, this);
|
||||||
|
@ -109,8 +112,15 @@ var Base = this.Base = new function() {
|
||||||
// the property exists (name in dest) and store result in prev
|
// the property exists (name in dest) and store result in prev
|
||||||
prev = preserve || func
|
prev = preserve || func
|
||||||
? (val && val.get ? name in dest : dest[name]) : null;
|
? (val && val.get ? name in dest : dest[name]) : null;
|
||||||
|
// Make generics first, as we might jump out bellow in the
|
||||||
|
// val !== (src.__proto__ || Object.prototype)[name] check,
|
||||||
|
// e.g. when explicitely reinjecting Array.prototype methods
|
||||||
|
// to produce generics of them.
|
||||||
if (generics && func && (!preserve || !generics[name])) {
|
if (generics && func && (!preserve || !generics[name])) {
|
||||||
generics[name] = function(bind) {
|
generics[name] = function(bind) {
|
||||||
|
// Do not call Array.slice generic here, as on Safari,
|
||||||
|
// this seems to confuse scopes (calling another
|
||||||
|
// generic from generic-producing code).
|
||||||
return bind && dest[name].apply(bind,
|
return bind && dest[name].apply(bind,
|
||||||
slice.call(arguments, 1));
|
slice.call(arguments, 1));
|
||||||
}
|
}
|
||||||
|
@ -121,6 +131,9 @@ var Base = this.Base = new function() {
|
||||||
if (prev && /\bthis\.base\b/.test(val)) {
|
if (prev && /\bthis\.base\b/.test(val)) {
|
||||||
var fromBase = base && base[name] == prev;
|
var fromBase = base && base[name] == prev;
|
||||||
res = function() {
|
res = function() {
|
||||||
|
// Look up the base function each time if we can,
|
||||||
|
// to reflect changes to the base class after
|
||||||
|
// inheritance.
|
||||||
var tmp = describe(this, 'base');
|
var tmp = describe(this, 'base');
|
||||||
define(this, 'base', { value: fromBase
|
define(this, 'base', { value: fromBase
|
||||||
? base[name] : prev, configurable: true });
|
? base[name] : prev, configurable: true });
|
||||||
|
@ -154,6 +167,7 @@ var Base = this.Base = new function() {
|
||||||
&& (bean = name.match(/^(get|is)(([A-Z])(.*))$/)))
|
&& (bean = name.match(/^(get|is)(([A-Z])(.*))$/)))
|
||||||
beans.push([ bean[3].toLowerCase() + bean[4], bean[2] ]);
|
beans.push([ bean[3].toLowerCase() + bean[4], bean[2] ]);
|
||||||
}
|
}
|
||||||
|
// No need to look up getter if this is a function already.
|
||||||
if (!res || func || !res.get && !res.set)
|
if (!res || func || !res.get && !res.set)
|
||||||
res = { value: res, writable: true };
|
res = { value: res, writable: true };
|
||||||
// Only set/change configurable and enumerable if this field is
|
// Only set/change configurable and enumerable if this field is
|
||||||
|
@ -233,8 +247,10 @@ var Base = this.Base = new function() {
|
||||||
|
|
||||||
function each(obj, iter, bind, asArray) {
|
function each(obj, iter, bind, asArray) {
|
||||||
try {
|
try {
|
||||||
(asArray || asArray === undefined && isArray(obj) ? forEach : forIn)
|
if (obj)
|
||||||
.call(obj, iterator(iter), bind = bind || obj);
|
(asArray || asArray === undefined && isArray(obj)
|
||||||
|
? forEach : forIn).call(obj, iterator(iter),
|
||||||
|
bind = bind || obj);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e !== Base.stop) throw e;
|
if (e !== Base.stop) throw e;
|
||||||
}
|
}
|
||||||
|
@ -261,8 +277,8 @@ var Base = this.Base = new function() {
|
||||||
src.preserve, src.generics && this);
|
src.preserve, src.generics && this);
|
||||||
// Define new static fields as enumerable, and inherit from
|
// Define new static fields as enumerable, and inherit from
|
||||||
// base. enumerable is necessary so they can be copied over from
|
// base. enumerable is necessary so they can be copied over from
|
||||||
// base, and it does not disturb to be enumerable in the
|
// base, and it does not harm to have enumerable properties in
|
||||||
// constructor. Use the preserve setting in src.preserve for
|
// the constructor. Use the preserve setting in src.preserve for
|
||||||
// statics too, not their own.
|
// statics too, not their own.
|
||||||
inject(this, statics, true, base, src.preserve);
|
inject(this, statics, true, base, src.preserve);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,9 @@
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Extend Base with utility functions used across the library.
|
// Extend Base with utility functions used across the library. Also set
|
||||||
Base.inject({
|
// this.Base, since bootstrap.js ommits that.
|
||||||
|
this.Base = Base.inject({
|
||||||
|
|
||||||
clone: function() {
|
clone: function() {
|
||||||
return new this.constructor(this);
|
return new this.constructor(this);
|
||||||
|
|
Loading…
Reference in a new issue