Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / ckeditor / js / plugins / drupallink / plugin.es6.js
index 7444fcc243827d97d68bece3d1ac6a205b11871e..8dddd2e1844082d5abb400cc0b1095442114141f 100644 (file)
 
   function getAttributes(editor, data) {
     const set = {};
-    for (const attributeName in data) {
-      if (data.hasOwnProperty(attributeName)) {
-        set[attributeName] = data[attributeName];
-      }
-    }
+    Object.keys(data || {}).forEach((attributeName) => {
+      set[attributeName] = data[attributeName];
+    });
 
     // CKEditor tracks the *actual* saved href in a data-cke-saved-* attribute
     // to work around browser quirks. We need to update it.
 
     // Remove all attributes which are not currently set.
     const removed = {};
-    for (const s in set) {
-      if (set.hasOwnProperty(s)) {
-        delete removed[s];
-      }
-    }
+    Object.keys(set).forEach((s) => {
+      delete removed[s];
+    });
 
     return {
       set,
             }
             // Update the link properties.
             else if (linkElement) {
-              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);
                 }
-              }
+                // Delete the property if set to an empty string.
+                else {
+                  linkElement.removeAttribute(attrName);
+                }
+              });
             }
 
             // Save snapshot for undo support.