Skip to content

Commit 1fcc6cc

Browse files
committed
rename variables to improve intelligibility of their semantics
1 parent 8fad978 commit 1fcc6cc

1 file changed

Lines changed: 18 additions & 16 deletions

File tree

src/dash/parser/objectiron.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,37 +46,39 @@ function ObjectIron(mappers) {
4646
return allowMapping;
4747
}
4848

49-
function _conditionallyMapProperty(exception, propertyParentElement, parentIsArray, parentEl, child) {
50-
if (_mappingAllowed(parentEl, exception)) {
51-
if (child[propertyParentElement]) {
49+
function _conditionallyMapProperty(exception, propertyName, propertyIsArray, propertyElementFromParent, childNode) {
50+
if (_mappingAllowed(propertyElementFromParent, exception)) {
51+
if (childNode[propertyName]) {
5252
// property already exists
53-
if (parentIsArray) {
54-
child[propertyParentElement].push(parentEl);
53+
if (propertyIsArray) {
54+
childNode[propertyName].push(propertyElementFromParent);
5555
}
56+
// if the propertyElementFromParent is not array and an element with same name is already present on child,
57+
// we don't want to overwrite this already existing version
5658
} else {
5759
// just add the property
58-
if (parentIsArray) {
59-
child[propertyParentElement] = [parentEl];
60+
if (propertyIsArray) {
61+
childNode[propertyName] = [propertyElementFromParent];
6062
} else {
61-
child[propertyParentElement] = parentEl;
63+
childNode[propertyName] = propertyElementFromParent;
6264
}
6365
}
6466
}
6567
}
6668

67-
function mapProperties(properties, exceptions, parent, child) {
69+
function mapProperties(properties, exceptions, parentNode, childNode) {
6870
for (let i = 0, len = properties.length; i < len; ++i) {
69-
const property = properties[i];
71+
const propertyName = properties[i];
7072

71-
if (parent[property]) {
72-
const propertyParentElement = parent[property];
73+
if (parentNode[propertyName]) {
74+
const propertyFromParentElement = parentNode[propertyName];
7375

74-
if (Array.isArray(propertyParentElement)) {
75-
propertyParentElement.forEach(propParentEl => {
76-
_conditionallyMapProperty(exceptions[property], property, true, propParentEl, child);
76+
if (Array.isArray(propertyFromParentElement)) {
77+
propertyFromParentElement.forEach(propParentEl => {
78+
_conditionallyMapProperty(exceptions[propertyName], propertyName, true, propParentEl, childNode);
7779
});
7880
} else {
79-
_conditionallyMapProperty(exceptions[property], property, false, propertyParentElement, child);
81+
_conditionallyMapProperty(exceptions[propertyName], propertyName, false, propertyFromParentElement, childNode);
8082
}
8183
}
8284
}

0 commit comments

Comments
 (0)