Skip to content

Commit ed4d425

Browse files
committed
fix: better fix for $compile problems in IE
Fixes #261
1 parent 47f59c8 commit ed4d425

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

dist/modules/ocLazyLoad.directive.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
(function (angular) {
22
'use strict';
33

4-
angular.module('oc.lazyLoad').directive('ocLazyLoad', ["$ocLazyLoad", "$compile", "$animate", "$parse", function ($ocLazyLoad, $compile, $animate, $parse) {
4+
angular.module('oc.lazyLoad').directive('ocLazyLoad', ["$ocLazyLoad", "$compile", "$animate", "$parse", "$timeout", function ($ocLazyLoad, $compile, $animate, $parse, $timeout) {
55
return {
66
restrict: 'A',
77
terminal: true,
88
priority: 1000,
99
compile: function compile(element, attrs) {
1010
// we store the content and remove it before compilation
11-
var content = element.contents();
11+
var content = element[0].innerHTML;
1212
element.html('');
1313

1414
return function ($scope, $element, $attr) {
@@ -21,9 +21,9 @@
2121
// Attach element contents to DOM and then compile them.
2222
// This prevents an issue where IE invalidates saved element objects (HTMLCollections)
2323
// of the compiled contents when attaching to the parent DOM.
24-
var contentElement = angular.element(content);
25-
$animate.enter(contentElement, $element);
26-
$compile(contentElement)($scope);
24+
$animate.enter(content, $element);
25+
// get the new content & compile it
26+
$compile($element.contents())($scope);
2727
});
2828
}
2929
}, true);

dist/ocLazyLoad.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -759,14 +759,14 @@
759759
(function (angular) {
760760
'use strict';
761761

762-
angular.module('oc.lazyLoad').directive('ocLazyLoad', ["$ocLazyLoad", "$compile", "$animate", "$parse", function ($ocLazyLoad, $compile, $animate, $parse) {
762+
angular.module('oc.lazyLoad').directive('ocLazyLoad', ["$ocLazyLoad", "$compile", "$animate", "$parse", "$timeout", function ($ocLazyLoad, $compile, $animate, $parse, $timeout) {
763763
return {
764764
restrict: 'A',
765765
terminal: true,
766766
priority: 1000,
767767
compile: function compile(element, attrs) {
768768
// we store the content and remove it before compilation
769-
var content = element.contents();
769+
var content = element[0].innerHTML;
770770
element.html('');
771771

772772
return function ($scope, $element, $attr) {
@@ -779,9 +779,9 @@
779779
// Attach element contents to DOM and then compile them.
780780
// This prevents an issue where IE invalidates saved element objects (HTMLCollections)
781781
// of the compiled contents when attaching to the parent DOM.
782-
var contentElement = angular.element(content);
783-
$animate.enter(contentElement, $element);
784-
$compile(contentElement)($scope);
782+
$animate.enter(content, $element);
783+
// get the new content & compile it
784+
$compile($element.contents())($scope);
785785
});
786786
}
787787
}, true);

dist/ocLazyLoad.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ocLazyLoad.require.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -759,14 +759,14 @@
759759
(function (angular) {
760760
'use strict';
761761

762-
angular.module('oc.lazyLoad').directive('ocLazyLoad', ["$ocLazyLoad", "$compile", "$animate", "$parse", function ($ocLazyLoad, $compile, $animate, $parse) {
762+
angular.module('oc.lazyLoad').directive('ocLazyLoad', ["$ocLazyLoad", "$compile", "$animate", "$parse", "$timeout", function ($ocLazyLoad, $compile, $animate, $parse, $timeout) {
763763
return {
764764
restrict: 'A',
765765
terminal: true,
766766
priority: 1000,
767767
compile: function compile(element, attrs) {
768768
// we store the content and remove it before compilation
769-
var content = element.contents();
769+
var content = element[0].innerHTML;
770770
element.html('');
771771

772772
return function ($scope, $element, $attr) {
@@ -779,9 +779,9 @@
779779
// Attach element contents to DOM and then compile them.
780780
// This prevents an issue where IE invalidates saved element objects (HTMLCollections)
781781
// of the compiled contents when attaching to the parent DOM.
782-
var contentElement = angular.element(content);
783-
$animate.enter(contentElement, $element);
784-
$compile(contentElement)($scope);
782+
$animate.enter(content, $element);
783+
// get the new content & compile it
784+
$compile($element.contents())($scope);
785785
});
786786
}
787787
}, true);

dist/ocLazyLoad.require.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ocLazyLoad.directive.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
(angular => {
22
'use strict';
33

4-
angular.module('oc.lazyLoad').directive('ocLazyLoad', function($ocLazyLoad, $compile, $animate, $parse) {
4+
angular.module('oc.lazyLoad').directive('ocLazyLoad', function($ocLazyLoad, $compile, $animate, $parse, $timeout) {
55
return {
66
restrict: 'A',
77
terminal: true,
88
priority: 1000,
99
compile: function(element, attrs) {
1010
// we store the content and remove it before compilation
11-
var content = element.contents();
11+
var content = element[0].innerHTML;
1212
element.html('');
1313

1414
return function($scope, $element, $attr) {
@@ -21,9 +21,9 @@
2121
// Attach element contents to DOM and then compile them.
2222
// This prevents an issue where IE invalidates saved element objects (HTMLCollections)
2323
// of the compiled contents when attaching to the parent DOM.
24-
var contentElement = angular.element(content);
25-
$animate.enter(contentElement, $element);
26-
$compile(contentElement)($scope);
24+
$animate.enter(content, $element);
25+
// get the new content & compile it
26+
$compile($element.contents())($scope);
2727
});
2828
}
2929
}, true);

0 commit comments

Comments
 (0)