Skip to content

Commit

Permalink
[Fix] PR - Styles overriding #29
Browse files Browse the repository at this point in the history
  • Loading branch information
sairamkiran9 committed Aug 12, 2024
1 parent 5e35990 commit 9affd24
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions library/core/survey.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,19 @@ class Survey {
deepMerge(target, source) {
if (!source || typeof source !== 'object') return target;
if (!target || typeof target !== 'object') return source;

const merged = { ...target };

// First pass: merge primary properties
Object.entries(source).forEach(([key, value]) => {
if (!(key.startsWith('&') || key.startsWith('@media'))) {
merged[key] = value;
}
});

// Second pass: handle special keys and ensure inherited properties

Object.entries(source).forEach(([key, value]) => {
if (key.startsWith('&') || key.startsWith('@media')) {
if(target[key]){
Object.entries(target[key]).forEach(([k,v]) => {
if(k in source) target[key][k] = source[k];
})
}
merged[key] = this.deepMerge(target[key] || {}, value);
} else {
merged[key] = value;
Object.entries(merged).forEach(([k, v]) => {
if (k.startsWith('&') || k.startsWith('@media')) {
merged[k] = {
Expand All @@ -151,7 +149,6 @@ class Survey {
});
}
});

return merged;
}

Expand Down

0 comments on commit 9affd24

Please sign in to comment.