Skip to content
This repository has been archived by the owner on May 25, 2021. It is now read-only.

Commit

Permalink
Remove lodash and also fix the 'constant updating' issue first seen i…
Browse files Browse the repository at this point in the history
…n the Raymond James app (which was also related to cloning) (#630)
  • Loading branch information
clbond authored Sep 9, 2016
1 parent a013066 commit 582b414
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@
"devDependencies": {
"autoprefixer": "^6.3.6",
"basscss-layout": "^3.1.0",
"clone": "^1.0.2",
"css-loader": "^0.21.0",
"es6-promise": "^3.1.2",
"es6-shim": "^0.35.0",
"file-loader": "^0.8.5",
"keycode": "^2.1.4",
"lodash": "^4.15.0",
"msgpack-lite": "^0.1.20",
"object-assign": "4.0.1",
"postcss-cssnext": "^2.5.2",
Expand Down
24 changes: 16 additions & 8 deletions src/tree/transformer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {cloneDeep} from 'lodash';
import * as clone from 'clone';

import {
ChangeDetectionStrategy,
Expand Down Expand Up @@ -61,7 +61,7 @@ export const transform = (
return load<Node>(serializedPath, () => {
const key = (subkey: string) => serializePath(path.concat([subkey]));

const listeners = element.listeners.map(l => cloneDeep(l));
const listeners = element.listeners.map(l => clone(l));

const name = (() => {
if (element.componentInstance &&
Expand Down Expand Up @@ -113,26 +113,34 @@ export const transform = (
? getComponentDirectives(metadata)
: [];

const assert = (): Node => {
throw new Error('Parent should already have been created and cached');
const cloneAndTransform = object => {
const copy = clone(object);

for (const k of Object.keys(copy)) {
if (copy[k] === undefined) { // undefined values cause json patch to misbehave
delete copy[k];
}
}

return copy;
};

const node: Node = {
id: serializedPath,
isComponent,
attributes: cloneDeep(element.attributes),
attributes: cloneAndTransform(element.attributes),
children: null,
changeDetection,
description: Description.getComponentDescription(element),
directives,
classes: cloneDeep(element.classes),
styles: cloneDeep(element.styles),
classes: cloneAndTransform(element.classes),
styles: cloneAndTransform(element.styles),
injectors,
input,
output,
name,
listeners,
properties: cloneDeep(element.properties),
properties: cloneAndTransform(element.properties),
providers,
dependencies: dependencies(),
source: element.source,
Expand Down
2 changes: 1 addition & 1 deletion typings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
"dependencies": {},
"globalDependencies": {
"chrome": "registry:dt/chrome#0.0.0+20160724063844",
"clone": "registry:dt/clone#0.1.11+20160317120654",
"d3": "registry:dt/d3#0.0.0+20160727131401",
"es6-shim": "registry:dt/es6-shim#0.31.2+20160602141504",
"filesystem": "registry:dt/filesystem#0.0.0+20160316155526",
"filewriter": "registry:dt/filewriter#0.0.0+20160316155526",
"lodash": "registry:dt/lodash#4.14.0+20160817155621",
"node": "registry:dt/node#6.0.0+20160823142437",
"tape": "registry:dt/tape#4.2.2+20160317120654",
"webrtc/mediastream": "registry:dt/webrtc/mediastream#0.0.0+20160317120654"
Expand Down

0 comments on commit 582b414

Please sign in to comment.