@@ -864,21 +864,38 @@ function UtilFactory($document, $timeout, $compile, $rootScope, $$mdAnimate, $in
864
864
} ,
865
865
866
866
/**
867
- * Function to get innerHTML of SVG and Symbol elements in IE11
867
+ * Gets the inner HTML content of the given HTMLElement.
868
+ * Only intended for use with SVG or Symbol elements in IE11.
868
869
* @param {Element } element
869
- * @returns {string } the innerHTML of the element passed in
870
+ * @returns {string } the inner HTML of the element passed in
870
871
*/
871
872
getInnerHTML : function ( element ) {
873
+ // For SVG or Symbol elements, innerHTML returns `undefined` in IE.
874
+ // Reference: https://stackoverflow.com/q/28129956/633107
875
+ // The XMLSerializer API is supported on IE11 and is the recommended workaround.
872
876
var serializer = new XMLSerializer ( ) ;
873
877
874
878
return Array . prototype . map . call ( element . childNodes , function ( child ) {
875
879
return serializer . serializeToString ( child ) ;
876
880
} ) . join ( '' ) ;
881
+ } ,
882
+
883
+ /**
884
+ * Gets the outer HTML content of the given HTMLElement.
885
+ * Only intended for use with SVG or Symbol elements in IE11.
886
+ * @param {Element } element
887
+ * @returns {string } the outer HTML of the element passed in
888
+ */
889
+ getOuterHTML : function ( element ) {
890
+ // For SVG or Symbol elements, outerHTML returns `undefined` in IE.
891
+ // Reference: https://stackoverflow.com/q/29888050/633107
892
+ // The XMLSerializer API is supported on IE11 and is the recommended workaround.
893
+ var serializer = new XMLSerializer ( ) ;
894
+ return serializer . serializeToString ( element ) ;
877
895
}
878
896
} ;
879
897
880
-
881
- // Instantiate other namespace utility methods
898
+ // Instantiate other namespace utility methods
882
899
883
900
$mdUtil . dom . animator = $$mdAnimate ( $mdUtil ) ;
884
901
@@ -887,7 +904,6 @@ function UtilFactory($document, $timeout, $compile, $rootScope, $$mdAnimate, $in
887
904
function getNode ( el ) {
888
905
return el [ 0 ] || el ;
889
906
}
890
-
891
907
}
892
908
893
909
/*
0 commit comments