Skip to content

Commit

Permalink
fix: better fix for $compile problems in IE
Browse files Browse the repository at this point in the history
Fixes #261
  • Loading branch information
ocombe committed Nov 2, 2015
1 parent 47f59c8 commit ed4d425
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
10 changes: 5 additions & 5 deletions dist/modules/ocLazyLoad.directive.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
(function (angular) {
'use strict';

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

return function ($scope, $element, $attr) {
Expand All @@ -21,9 +21,9 @@
// Attach element contents to DOM and then compile them.
// This prevents an issue where IE invalidates saved element objects (HTMLCollections)
// of the compiled contents when attaching to the parent DOM.
var contentElement = angular.element(content);
$animate.enter(contentElement, $element);
$compile(contentElement)($scope);
$animate.enter(content, $element);
// get the new content & compile it
$compile($element.contents())($scope);
});
}
}, true);
Expand Down
10 changes: 5 additions & 5 deletions dist/ocLazyLoad.js
Original file line number Diff line number Diff line change
Expand Up @@ -759,14 +759,14 @@
(function (angular) {
'use strict';

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

return function ($scope, $element, $attr) {
Expand All @@ -779,9 +779,9 @@
// Attach element contents to DOM and then compile them.
// This prevents an issue where IE invalidates saved element objects (HTMLCollections)
// of the compiled contents when attaching to the parent DOM.
var contentElement = angular.element(content);
$animate.enter(contentElement, $element);
$compile(contentElement)($scope);
$animate.enter(content, $element);
// get the new content & compile it
$compile($element.contents())($scope);
});
}
}, true);
Expand Down
2 changes: 1 addition & 1 deletion dist/ocLazyLoad.min.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions dist/ocLazyLoad.require.js
Original file line number Diff line number Diff line change
Expand Up @@ -759,14 +759,14 @@
(function (angular) {
'use strict';

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

return function ($scope, $element, $attr) {
Expand All @@ -779,9 +779,9 @@
// Attach element contents to DOM and then compile them.
// This prevents an issue where IE invalidates saved element objects (HTMLCollections)
// of the compiled contents when attaching to the parent DOM.
var contentElement = angular.element(content);
$animate.enter(contentElement, $element);
$compile(contentElement)($scope);
$animate.enter(content, $element);
// get the new content & compile it
$compile($element.contents())($scope);
});
}
}, true);
Expand Down
2 changes: 1 addition & 1 deletion dist/ocLazyLoad.require.min.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions src/ocLazyLoad.directive.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
(angular => {
'use strict';

angular.module('oc.lazyLoad').directive('ocLazyLoad', function($ocLazyLoad, $compile, $animate, $parse) {
angular.module('oc.lazyLoad').directive('ocLazyLoad', function($ocLazyLoad, $compile, $animate, $parse, $timeout) {
return {
restrict: 'A',
terminal: true,
priority: 1000,
compile: function(element, attrs) {
// we store the content and remove it before compilation
var content = element.contents();
var content = element[0].innerHTML;
element.html('');

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

0 comments on commit ed4d425

Please # to comment.