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

Commit 9a027b4

Browse files
Goamandmo-odoo
authored andcommitted
[IMP] Core: downgrage build to es2017
Currently Odoo is configured to suppot maximum es2017.
1 parent 4121655 commit 9a027b4

File tree

10 files changed

+38
-32
lines changed

10 files changed

+38
-32
lines changed

packages/plugin-devtools/src/components/CommandsComponent.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { OwlComponent } from '../../../plugin-owl/src/OwlComponent';
22
import { CommandIdentifier } from '../../../core/src/Dispatcher';
33
import { CommandParams } from '../../../core/src/Dispatcher';
44
import { CommandImplementation } from '../../../core/src/Dispatcher';
5-
import { nodeName } from '../../../utils/src/utils';
5+
import { nodeName, flat } from '../../../utils/src/utils';
66
import { Keymap, Mapping } from '../../../plugin-keymap/src/Keymap';
77
import { argsRepr } from '../utils';
88

@@ -107,9 +107,8 @@ export class CommandsComponent extends OwlComponent<CommandsProps> {
107107
* @param commandIdentifier
108108
*/
109109
matchingMappings(commandIdentifier: string): Mapping[] {
110-
return this.env.editor.plugins
111-
.get(Keymap)
112-
.mappings.flat()
113-
.filter(mapping => mapping.configuredCommand.commandId === commandIdentifier);
110+
return flat(this.env.editor.plugins.get(Keymap).mappings).filter(
111+
mapping => mapping.configuredCommand.commandId === commandIdentifier,
112+
);
114113
}
115114
}

packages/plugin-devtools/src/components/ShortcutsComponent.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import { OwlComponent } from '../../../plugin-owl/src/OwlComponent';
22
import { Keymap } from '../../../plugin-keymap/src/Keymap';
33
import { argsRepr } from '../utils';
4+
import { flat } from '../../../utils/src/utils';
45

56
export class ShortcutsComponent extends OwlComponent<{}> {
6-
mappings = this.env.editor.plugins
7-
.get(Keymap)
8-
.mappings.flat()
9-
.sort((a, b) => {
10-
if (a.configuredCommand.commandId < b.configuredCommand.commandId) return -1;
11-
if (a.configuredCommand.commandId > b.configuredCommand.commandId) return 1;
12-
return 0;
13-
});
7+
mappings = flat(this.env.editor.plugins.get(Keymap).mappings).sort((a, b) => {
8+
if (a.configuredCommand.commandId < b.configuredCommand.commandId) return -1;
9+
if (a.configuredCommand.commandId > b.configuredCommand.commandId) return 1;
10+
return 0;
11+
});
1412
localStorage = ['currentTab'];
1513
argsRepr = argsRepr;
1614
stringifyPattern = this.env.editor.plugins.get(Keymap).stringifyPattern;

packages/plugin-dom-layout/src/DomLayoutEngine.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { DomReconciliationEngine } from './DomReconciliationEngine';
1515
import { LayoutContainer } from './LayoutContainerNode';
1616
import { DomObject } from '../../plugin-renderer-dom-object/src/DomObjectRenderingEngine';
1717
import { VElement } from '../../core/src/VNodes/VElement';
18+
import { flat } from '../../utils/src/utils';
1819

1920
export type DomPoint = [Node, number];
2021
export type DomLayoutLocation = [Node, DomZonePosition];
@@ -53,11 +54,7 @@ export class DomLayoutEngine extends LayoutEngine {
5354
throw new Error('Layout component "' + componentId + '" not found.');
5455
}
5556
}
56-
if (
57-
!Object.values(this.componentZones)
58-
.flat()
59-
.includes('root')
60-
) {
57+
if (!flat(Object.values(this.componentZones)).includes('root')) {
6158
this.componentDefinitions.editor = this.defaultRootComponent;
6259
this.componentZones.editor = ['root'];
6360
}

packages/plugin-dom-layout/src/DomReconciliationEngine.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { VNode, Point, RelativePosition } from '../../core/src/VNodes/VNode';
2-
import { nodeName, nodeLength, FlattenUnion } from '../../utils/src/utils';
2+
import { nodeName, nodeLength, FlattenUnion, flat } from '../../utils/src/utils';
33
import { styleToObject } from '../../utils/src/Dom';
44
import { AbstractNode } from '../../core/src/VNodes/AbstractNode';
55
import { ContainerNode } from '../../core/src/VNodes/ContainerNode';
@@ -1218,16 +1218,18 @@ export class DomReconciliationEngine {
12181218
// Insert children in the dom which locate with the placeholder.
12191219
for (const [ref, position, childIds] of object.domNodesChildren) {
12201220
if (position === RelativePosition.INSIDE) {
1221-
const childDomNodes = childIds
1222-
.map(childId => this._getDomChild(childId, ref as Element | ShadowRoot))
1223-
.flat();
1221+
const childDomNodes = flat(
1222+
childIds.map(childId =>
1223+
this._getDomChild(childId, ref as Element | ShadowRoot),
1224+
),
1225+
);
12241226
for (const domNode of childDomNodes) {
12251227
ref.appendChild(domNode);
12261228
}
12271229
} else {
1228-
const childDomNodes = childIds
1229-
.map(childId => this._getDomChild(childId, ref.parentElement))
1230-
.flat();
1230+
const childDomNodes = flat(
1231+
childIds.map(childId => this._getDomChild(childId, ref.parentElement)),
1232+
);
12311233
if (position === RelativePosition.BEFORE) {
12321234
for (const domNode of childDomNodes) {
12331235
ref.parentElement.insertBefore(domNode, ref);

packages/plugin-dom-layout/test/DomLayout.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { InlineNode } from '../../plugin-inline/src/InlineNode';
4545
import { Attributes } from '../../plugin-xml/src/Attributes';
4646
import { parseElement } from '../../utils/src/configuration';
4747
import { Html } from '../../plugin-html/src/Html';
48+
import { flat } from '../../utils/src/utils';
4849

4950
const container = document.createElement('div');
5051
container.classList.add('container');
@@ -3011,7 +3012,7 @@ describe('DomLayout', () => {
30113012
await engine.redraw(
30123013
div,
30133014
...div.childVNodes,
3014-
...div.childVNodes.map(n => n.childVNodes).flat(),
3015+
...flat(div.childVNodes.map(n => n.childVNodes)),
30153016
);
30163017

30173018
expect(sectionDom.innerHTML).to.equal('<div><p>ab</p><p>cdz</p></div>');
@@ -3083,7 +3084,7 @@ describe('DomLayout', () => {
30833084
await engine.redraw(
30843085
div,
30853086
...div.childVNodes,
3086-
...div.childVNodes.map(n => n.childVNodes).flat(),
3087+
...flat(div.childVNodes.map(n => n.childVNodes)),
30873088
);
30883089

30893090
expect(sectionDom.innerHTML).to.equal('<div><p>ab</p><p>cd</p></div>');

packages/plugin-list/src/ListDomObjectRenderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class ListDomObjectRenderer extends AbstractRenderer<DomObject> {
2828
}
2929
}
3030
const renderedChildren = await this.engine.renderChildren(node);
31-
domObject.children.push(...renderedChildren.flat());
31+
domObject.children.push(...renderedChildren);
3232
return domObject;
3333
}
3434
}

packages/plugin-renderer-dom-object/src/DomObjectRenderingEngine.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { AtomicNode } from '../../core/src/VNodes/AtomicNode';
55
import { Attributes } from '../../plugin-xml/src/Attributes';
66
import { AbstractNode } from '../../core/src/VNodes/AbstractNode';
77
import { Format } from '../../core/src/Format';
8+
import { flat } from '../../utils/src/utils';
89

910
/**
1011
* Renderer a node can define the location when define the nodes attributes.
@@ -378,12 +379,12 @@ export class DomObjectRenderingEngine extends RenderingEngine<DomObject> {
378379

379380
// Render wrapped nodes.
380381
const renderingGroups = this._renderBatched(newRenderingUnits);
381-
const nodes = renderingGroups.map(u => u[0]).flat();
382+
const nodes = flat(renderingGroups.map(u => u[0]));
382383

383384
const promises = renderingGroups.map(u => u[1]);
384385
const promise = Promise.all(promises);
385386
const unitPromise = promise.then(async domObjectLists => {
386-
const flatten = domObjectLists.flat();
387+
const flatten = flat(domObjectLists);
387388
const domObjects: DomObject[] = [];
388389
for (const domObject of flatten) {
389390
if (!domObjects.includes(domObject)) {

packages/plugin-renderer/src/AbstractRenderer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Renderer, RenderingIdentifier, RendererConstructor } from './RenderingEngine';
22
import { RenderingEngine } from './RenderingEngine';
33
import { VNode, Predicate } from '../../core/src/VNodes/VNode';
4+
import { flat } from '../../utils/src/utils';
45

56
class SuperRenderer<T> implements Renderer<T> {
67
static id = 'super';
@@ -26,7 +27,7 @@ class SuperRenderer<T> implements Renderer<T> {
2627
for (const [, rendering] of groups) {
2728
renderings.push(rendering);
2829
}
29-
return (await Promise.all(renderings)).flat();
30+
return flat(await Promise.all(renderings));
3031
}
3132
}
3233

packages/utils/src/utils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ export function deepEqualObjects(a: object, b: object): boolean {
3434
return true;
3535
}
3636

37+
/**
38+
* Creates a new array with all sub-array elements concatenated into it.
39+
*/
40+
export function flat<T>(arr: T[][]): T[] {
41+
return [].concat(...arr);
42+
}
43+
3744
/**
3845
* Convert certain special characters to unicode.
3946
*/

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"target": "es2019",
3+
"target": "es2017",
44
"incremental": true,
55
"moduleResolution": "node",
66
"sourceMap": true

0 commit comments

Comments
 (0)