function getAttributes(editor, data) {
var set = {};
- for (var attributeName in data) {
- if (data.hasOwnProperty(attributeName)) {
- set[attributeName] = data[attributeName];
- }
- }
+ Object.keys(data || {}).forEach(function (attributeName) {
+ set[attributeName] = data[attributeName];
+ });
set['data-cke-saved-href'] = set.href;
var removed = {};
- for (var s in set) {
- if (set.hasOwnProperty(s)) {
- delete removed[s];
- }
- }
+ Object.keys(set).forEach(function (s) {
+ delete removed[s];
+ });
return {
set: set,
linkElement = getSelectedLink(editor);
} else if (linkElement) {
- for (var attrName in returnValues.attributes) {
- if (returnValues.attributes.hasOwnProperty(attrName)) {
- if (returnValues.attributes[attrName].length > 0) {
- var value = returnValues.attributes[attrName];
- linkElement.data('cke-saved-' + attrName, value);
- linkElement.setAttribute(attrName, value);
- } else {
- linkElement.removeAttribute(attrName);
- }
- }
- }
+ Object.keys(returnValues.attributes || {}).forEach(function (attrName) {
+ if (returnValues.attributes[attrName].length > 0) {
+ var value = returnValues.attributes[attrName];
+ linkElement.data('cke-saved-' + attrName, value);
+ linkElement.setAttribute(attrName, value);
+ } else {
+ linkElement.removeAttribute(attrName);
+ }
+ });
}
editor.fire('saveSnapshot');