Skip to content

Commit 27ab0c3

Browse files
committed
remove merge flag form MapNode
1 parent a4b1750 commit 27ab0c3

5 files changed

Lines changed: 11 additions & 126 deletions

File tree

src/dash/parser/maps/CommonProperty.js

Lines changed: 0 additions & 54 deletions
This file was deleted.

src/dash/parser/maps/MapNode.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,13 @@
3131
/**
3232
* @classdesc a node at some level in a ValueMap
3333
*/
34-
import CommonProperty from './CommonProperty.js';
3534

3635
class MapNode {
3736
constructor(name, properties, exceptions, children) {
3837
this._name = name || '';
39-
this._properties = [];
38+
this._properties = properties || [];
4039
this._exceptions = exceptions || {};
4140
this._children = children || [];
42-
43-
if (Array.isArray(properties)) {
44-
properties.forEach(p => {
45-
this._properties.push(new CommonProperty(p));
46-
});
47-
}
4841
}
4942

5043
get name() {

src/dash/parser/objectiron.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,12 @@ function ObjectIron(mappers) {
4646
return allowMapping;
4747
}
4848

49-
function _conditionallyMapProperty(exception, propertyParentElement, parentIsArray, parentEl, child, mergeFlag) {
49+
function _conditionallyMapProperty(exception, propertyParentElement, parentIsArray, parentEl, child) {
5050
if (_mappingAllowed(parentEl, exception)) {
5151
if (child[propertyParentElement]) {
5252
// property already exists
53-
// check to see if we should merge
54-
if (mergeFlag) {
55-
if (parentIsArray) {
56-
child[propertyParentElement].push(parentEl);
57-
}
53+
if (parentIsArray) {
54+
child[propertyParentElement].push(parentEl);
5855
}
5956
} else {
6057
// just add the property
@@ -71,15 +68,15 @@ function ObjectIron(mappers) {
7168
for (let i = 0, len = properties.length; i < len; ++i) {
7269
const property = properties[i];
7370

74-
if (parent[property.name]) {
75-
const propertyParentElement = parent[property.name];
71+
if (parent[property]) {
72+
const propertyParentElement = parent[property];
7673

7774
if (Array.isArray(propertyParentElement)) {
7875
propertyParentElement.forEach(propParentEl => {
79-
_conditionallyMapProperty(exceptions[property.name], property.name, true, propParentEl, child, property.merge);
76+
_conditionallyMapProperty(exceptions[property], property, true, propParentEl, child);
8077
});
8178
} else {
82-
_conditionallyMapProperty(exceptions[property.name], property.name, false, propertyParentElement, child, property.merge);
79+
_conditionallyMapProperty(exceptions[property], property, false, propertyParentElement, child);
8380
}
8481
}
8582
}

test/unit/test/dash/dash.parser.maps.CommonProperty.js

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import MapNode from '../../../../src/dash/parser/maps/MapNode.js';
2-
import CommonProperty from '../../../../src/dash/parser/maps/CommonProperty.js';
32
import {expect} from 'chai';
43

54
describe('MapNode', function () {
@@ -13,25 +12,16 @@ describe('MapNode', function () {
1312
expect(mapNode.properties).to.be.empty; // jshint ignore:line
1413
expect(mapNode.children).to.be.instanceOf(Array); // jshint ignore:line
1514
expect(mapNode.children).to.be.empty; // jshint ignore:line
15+
expect(mapNode.exceptions).to.be.instanceOf(Object); // jshint ignore:line
16+
expect(mapNode.exceptions).to.be.empty; // jshint ignore:line
1617
});
1718

1819
it('should throw an exception if attempting to use setters', () => {
1920
const mapNode = new MapNode();
2021

21-
['name', 'properties', 'children'].forEach(p => {
22+
['name', 'properties', 'children', 'exceptions'].forEach(p => {
2223
const f = () => mapNode[p] = p;
2324
expect(f).to.throw(Error);
2425
});
2526
});
26-
27-
it('should have CommonProperty\'s', () => {
28-
const name = '';
29-
const properties = ['test'];
30-
31-
const mapNode = new MapNode(name, properties);
32-
33-
expect(mapNode.properties).to.be.instanceOf(Array); // jshint ignore:line
34-
expect(mapNode.properties).not.to.be.empty; // jshint ignore:line
35-
expect(mapNode.properties[0]).to.be.instanceOf(CommonProperty); // jshint ignore:line
36-
});
3727
});

0 commit comments

Comments
 (0)