Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/icon/js/iconService.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ function MdIconService(config, $templateRequest, $q, $log, $mdUtil, $sce) {
});
// innerHTML of SVG elements is not supported by IE11
if (clone.innerHTML === undefined) {
svgElement = $mdUtil.getInnerHTML(clone);
svgElement = $mdUtil.getOuterHTML(clone);
svgElement = svgElement.replace(/(.*url\(#)(\w*)(\).*)/g, addCacheSuffixToId);
svgElement = svgElement.replace(/(.*xlink:href="#)(\w*)(".*)/g, addCacheSuffixToId);
clone = angular.element(svgElement)[0];
Expand Down
26 changes: 21 additions & 5 deletions src/core/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -864,21 +864,38 @@ function UtilFactory($document, $timeout, $compile, $rootScope, $$mdAnimate, $in
},

/**
* Function to get innerHTML of SVG and Symbol elements in IE11
* Gets the inner HTML content of the given HTMLElement.
* Only intended for use with SVG or Symbol elements in IE11.
* @param {Element} element
* @returns {string} the innerHTML of the element passed in
* @returns {string} the inner HTML of the element passed in
*/
getInnerHTML: function(element) {
// For SVG or Symbol elements, innerHTML returns `undefined` in IE.
// Reference: https://stackoverflow.com/q/28129956/633107
// The XMLSerializer API is supported on IE11 and is the recommended workaround.
var serializer = new XMLSerializer();

return Array.prototype.map.call(element.childNodes, function (child) {
return serializer.serializeToString(child);
}).join('');
},

/**
* Gets the outer HTML content of the given HTMLElement.
* Only intended for use with SVG or Symbol elements in IE11.
* @param {Element} element
* @returns {string} the outer HTML of the element passed in
*/
getOuterHTML: function(element) {
// For SVG or Symbol elements, outerHTML returns `undefined` in IE.
// Reference: https://stackoverflow.com/q/29888050/633107
// The XMLSerializer API is supported on IE11 and is the recommended workaround.
var serializer = new XMLSerializer();
return serializer.serializeToString(element);
}
};


// Instantiate other namespace utility methods
// Instantiate other namespace utility methods

$mdUtil.dom.animator = $$mdAnimate($mdUtil);

Expand All @@ -887,7 +904,6 @@ function UtilFactory($document, $timeout, $compile, $rootScope, $$mdAnimate, $in
function getNode(el) {
return el[0] || el;
}

}

/*
Expand Down