2018-11-05 05:06:39 -05:00
|
|
|
/* eslint-disable
|
|
|
|
max-len,
|
|
|
|
*/
|
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
// Fix any style issues and re-enable lint.
|
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
|
|
|
//
|
|
|
|
// * An Angular service which helps with creating recursive directives.
|
|
|
|
// * @author Mark Lagendijk
|
|
|
|
// * @license MIT
|
|
|
|
//
|
|
|
|
// From: https://github.com/marklagendijk/angular-recursion
|
2020-05-19 05:02:56 -04:00
|
|
|
/* eslint-disable
|
|
|
|
max-len,
|
|
|
|
*/
|
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
// Fix any style issues and re-enable lint.
|
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
|
|
|
//
|
|
|
|
// * An Angular service which helps with creating recursive directives.
|
|
|
|
// * @author Mark Lagendijk
|
|
|
|
// * @license MIT
|
|
|
|
//
|
|
|
|
// From: https://github.com/marklagendijk/angular-recursion
|
2018-11-05 05:06:39 -05:00
|
|
|
angular.module('RecursionHelper', []).factory('RecursionHelper', [
|
|
|
|
'$compile',
|
2021-04-14 09:17:21 -04:00
|
|
|
function ($compile) {
|
2018-11-05 05:06:39 -05:00
|
|
|
/*
|
|
|
|
Manually compiles the element, fixing the recursion loop.
|
|
|
|
@param element
|
|
|
|
@param [link] A post-link function, or an object with function(s) registered via pre and post properties.
|
|
|
|
@returns An object containing the linking functions.
|
|
|
|
*/
|
|
|
|
return {
|
|
|
|
compile(element, link) {
|
|
|
|
// Normalize the link parameter
|
|
|
|
if (angular.isFunction(link)) {
|
|
|
|
link = { post: link }
|
|
|
|
}
|
|
|
|
|
|
|
|
// Break the recursion loop by removing the contents
|
|
|
|
const contents = element.contents().remove()
|
|
|
|
let compiledContents
|
|
|
|
return {
|
|
|
|
pre: link && link.pre ? link.pre : null,
|
|
|
|
|
|
|
|
/*
|
|
|
|
Compiles and re-adds the contents
|
|
|
|
*/
|
|
|
|
post(scope, element) {
|
|
|
|
// Compile the contents
|
|
|
|
if (!compiledContents) {
|
|
|
|
compiledContents = $compile(contents)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Re-add the compiled contents to the element
|
2021-04-14 09:17:21 -04:00
|
|
|
compiledContents(scope, function (clone) {
|
2018-11-05 05:06:39 -05:00
|
|
|
element.append(clone)
|
|
|
|
})
|
|
|
|
|
|
|
|
// Call the post-linking function, if any
|
|
|
|
if (link && link.post) {
|
|
|
|
link.post.apply(null, arguments)
|
|
|
|
}
|
2021-04-27 03:52:58 -04:00
|
|
|
},
|
2018-11-05 05:06:39 -05:00
|
|
|
}
|
2021-04-27 03:52:58 -04:00
|
|
|
},
|
2018-11-05 05:06:39 -05:00
|
|
|
}
|
2021-04-27 03:52:58 -04:00
|
|
|
},
|
2018-11-05 05:06:39 -05:00
|
|
|
])
|