2 * Get all attributes of an element
4 * IE gives wrong results for hasAttribute/getAttribute, for example:
5 * var td = document.createElement("td");
6 * td.getAttribute("rowspan"); // => "1" in IE
8 * Therefore we have to check the element's outerHTML for the attribute
11 wysihtml5.dom.getAttributes = function(node) {
12 var HAS_GET_ATTRIBUTE_BUG = !wysihtml5.browser.supportsGetAttributeCorrectly(),
13 nodeName = node.nodeName,
17 for (attr in node.attributes) {
18 if ((node.attributes.hasOwnProperty && node.attributes.hasOwnProperty(attr)) || (!node.attributes.hasOwnProperty && Object.prototype.hasOwnProperty.call(node.attributes, attr))) {
19 if (node.attributes[attr].specified) {
20 if (nodeName == "IMG" && node.attributes[attr].name.toLowerCase() == "src" && wysihtml5.dom.isLoadedImage(node) === true) {
21 attributes['src'] = node.src;
22 } else if (wysihtml5.lang.array(['rowspan', 'colspan']).contains(node.attributes[attr].name.toLowerCase()) && HAS_GET_ATTRIBUTE_BUG) {
23 if (node.attributes[attr].value !== 1) {
24 attributes[node.attributes[attr].name] = node.attributes[attr].value;
27 attributes[node.attributes[attr].name] = node.attributes[attr].value;