- for (const attrName in returnValues.attributes) {
- if (returnValues.attributes.hasOwnProperty(attrName)) {
- // Update the property if a value is specified.
- if (returnValues.attributes[attrName].length > 0) {
- const value = returnValues.attributes[attrName];
- linkElement.data(`cke-saved-${attrName}`, value);
- linkElement.setAttribute(attrName, value);
- }
- // Delete the property if set to an empty string.
- else {
- linkElement.removeAttribute(attrName);
- }
+ Object.keys(returnValues.attributes || {}).forEach((attrName) => {
+ // Update the property if a value is specified.
+ if (returnValues.attributes[attrName].length > 0) {
+ const value = returnValues.attributes[attrName];
+ linkElement.data(`cke-saved-${attrName}`, value);
+ linkElement.setAttribute(attrName, value);