mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
refactor(util): use Object.assign polyfill
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {getQuerystring, extend} from '../util/util';
|
||||
import {getQuerystring, assign} from '../util/util';
|
||||
import {ready, windowDimensions, flushDimensionCache} from '../util/dom';
|
||||
|
||||
|
||||
@@ -513,8 +513,8 @@ export class Platform {
|
||||
// add the engine to the first in the platform hierarchy
|
||||
// the original rootPlatformNode now becomes a child
|
||||
// of the engineNode, which is not the new root
|
||||
engineNode.child(rootPlatformNode);
|
||||
rootPlatformNode.parent(engineNode);
|
||||
engineNode.child = rootPlatformNode;
|
||||
rootPlatformNode.parent = engineNode;
|
||||
rootPlatformNode = engineNode;
|
||||
|
||||
// add any events which the engine would provide
|
||||
@@ -522,21 +522,21 @@ export class Platform {
|
||||
let engineMethods = engineNode.methods();
|
||||
engineMethods._engineReady = engineMethods.ready;
|
||||
delete engineMethods.ready;
|
||||
extend(this, engineMethods);
|
||||
assign(this, engineMethods);
|
||||
}
|
||||
|
||||
let platformNode = rootPlatformNode;
|
||||
while (platformNode) {
|
||||
insertSuperset(platformNode);
|
||||
platformNode = platformNode.child();
|
||||
platformNode = platformNode.child;
|
||||
}
|
||||
|
||||
// make sure the root noot is actually the root
|
||||
// incase a node was inserted before the root
|
||||
platformNode = rootPlatformNode.parent();
|
||||
platformNode = rootPlatformNode.parent;
|
||||
while (platformNode) {
|
||||
rootPlatformNode = platformNode;
|
||||
platformNode = platformNode.parent();
|
||||
platformNode = platformNode.parent;
|
||||
}
|
||||
|
||||
platformNode = rootPlatformNode;
|
||||
@@ -549,7 +549,7 @@ export class Platform {
|
||||
this._versions[platformNode.name()] = platformNode.version(this);
|
||||
|
||||
// go to the next platform child
|
||||
platformNode = platformNode.child();
|
||||
platformNode = platformNode.child;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -566,14 +566,14 @@ export class Platform {
|
||||
// use it's getRoot method to build up its hierarchy
|
||||
// depending on which platforms match
|
||||
let platformNode = new PlatformNode(platformName);
|
||||
let rootNode = platformNode.getRoot(this, 0);
|
||||
let rootNode = platformNode.getRoot(this);
|
||||
|
||||
if (rootNode) {
|
||||
rootNode.depth = 0;
|
||||
let childPlatform = rootNode.child();
|
||||
let childPlatform = rootNode.child;
|
||||
while (childPlatform) {
|
||||
rootNode.depth++;
|
||||
childPlatform = childPlatform.child();
|
||||
childPlatform = childPlatform.child;
|
||||
}
|
||||
}
|
||||
return rootNode;
|
||||
@@ -587,20 +587,20 @@ function insertSuperset(platformNode) {
|
||||
// add a platform in between two exist platforms
|
||||
// so we can build the correct hierarchy of active platforms
|
||||
let supersetPlatform = new PlatformNode(supersetPlaformName);
|
||||
supersetPlatform.parent(platformNode.parent());
|
||||
supersetPlatform.child(platformNode);
|
||||
if (supersetPlatform.parent()) {
|
||||
supersetPlatform.parent().child(supersetPlatform);
|
||||
supersetPlatform.parent = platformNode.parent;
|
||||
supersetPlatform.child = platformNode;
|
||||
if (supersetPlatform.parent) {
|
||||
supersetPlatform.parent.child = supersetPlatform;
|
||||
}
|
||||
platformNode.parent(supersetPlatform);
|
||||
platformNode.parent = supersetPlatform;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class PlatformNode {
|
||||
private c: any;
|
||||
private _parent: PlatformNode;
|
||||
private _child: PlatformNode;
|
||||
public parent: PlatformNode;
|
||||
public child: PlatformNode;
|
||||
public isEngine: boolean;
|
||||
|
||||
constructor(platformName) {
|
||||
@@ -624,20 +624,6 @@ class PlatformNode {
|
||||
return this.c.methods || {};
|
||||
}
|
||||
|
||||
parent(val) {
|
||||
if (arguments.length) {
|
||||
this._parent = val;
|
||||
}
|
||||
return this._parent;
|
||||
}
|
||||
|
||||
child(val) {
|
||||
if (arguments.length) {
|
||||
this._child = val;
|
||||
}
|
||||
return this._child;
|
||||
}
|
||||
|
||||
isMatch(p): boolean {
|
||||
if (p.platformOverride && !this.isEngine) {
|
||||
return (p.platformOverride === this.c.name);
|
||||
@@ -678,11 +664,11 @@ class PlatformNode {
|
||||
|
||||
for (let i = 0; i < parents.length; i++) {
|
||||
platform = new PlatformNode(parents[i]);
|
||||
platform.child(this);
|
||||
platform.child = this;
|
||||
|
||||
rootPlatform = platform.getRoot(p);
|
||||
if (rootPlatform) {
|
||||
this.parent(platform);
|
||||
this.parent = platform;
|
||||
return rootPlatform;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {StorageEngine} from './storage';
|
||||
|
||||
import {defaults, extend} from '../../util';
|
||||
import {defaults, assign} from '../../util/util';
|
||||
|
||||
const DB_NAME :string = '__ionicstorage';
|
||||
const win :any = window;
|
||||
@@ -54,7 +54,7 @@ export class SqlStorage extends StorageEngine {
|
||||
if (win.sqlitePlugin) {
|
||||
let location = this._getBackupLocation(dbOptions.backupFlag);
|
||||
|
||||
this._db = win.sqlitePlugin.openDatabase(extend({
|
||||
this._db = win.sqlitePlugin.openDatabase(assign({
|
||||
name: dbOptions.name,
|
||||
location: location,
|
||||
createFromLocation: dbOptions.existingDatabase ? 1 : 0
|
||||
|
||||
Reference in New Issue
Block a user