Skip to content

Commit

Permalink
Fixed more bugs introduced by showing ZAPped classes (#104), follow u…
Browse files Browse the repository at this point in the history
…p to #113
  • Loading branch information
raffazizzi committed Nov 16, 2020
1 parent 7ccd014 commit fe8ce2d
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/reducers/elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export function oddElements(state, action) {
}
}
})
const localClass = localsource.classes.attributes.filter(c => (c.ident === action.className))[0]
let localClass = localsource.classes.attributes.filter(c => (c.ident === action.className))[0]
if (customization.classes.attributes.filter(c => (c.ident === action.className)).length === 0) {
customization.classes.attributes.push(localClass)
}
Expand Down Expand Up @@ -374,7 +374,13 @@ export function oddElements(state, action) {
return newState
case DELETE_CLASS_ATTRIBUTE_ON_ELEMENT:
let customClass = customization.classes.attributes.filter(c => (c.ident === action.className))[0]
const attribute = customClass.attributes.filter(a => a.ident === action.attName)[0]
let attribute
if (customClass) {
attribute = customClass.attributes.filter(a => a.ident === action.attName)[0]
} else {
localClass = localsource.classes.attributes.filter(c => (c.ident === action.className))[0]
attribute = localClass.attributes.filter(a => a.ident === action.attName)[0]
}
customization.elements.forEach(m => {
if (m.ident === action.element) {
deleteAttribute(m, attribute)
Expand All @@ -384,7 +390,13 @@ export function oddElements(state, action) {
return newState
case CHANGE_CLASS_ATTRIBUTE_ON_ELEMENT:
customClass = customization.classes.attributes.filter(c => (c.ident === action.className))[0]
const attributeToChange = customClass.attributes.filter(a => a.ident === action.attName)[0]
let attributeToChange
if (customClass) {
attributeToChange = customClass.attributes.filter(a => a.ident === action.attName)[0]
} else {
localClass = localsource.classes.attributes.filter(c => (c.ident === action.className))[0]
attributeToChange = localClass.attributes.filter(a => a.ident === action.attName)[0]
}
customization.elements.forEach(m => {
if (m.ident === action.element) {
const newAtt = Object.assign({}, attributeToChange, {mode: 'change', changed: false, _fromClass: action.className})
Expand Down

0 comments on commit fe8ce2d

Please sign in to comment.