mirror of
https://github.com/nasa/openmct.git
synced 2025-06-16 06:08:11 +00:00
[Representation] Handle edge cases
Handle edge cases (e.g. directive priorities, race conditions) to ensure that mct-representation and mct-include display correctly when added to or removed from the DOM.
This commit is contained in:
@ -84,6 +84,9 @@ define(
|
|||||||
// Use the included controller to populate scope
|
// Use the included controller to populate scope
|
||||||
link: link,
|
link: link,
|
||||||
|
|
||||||
|
// May hide the element, so let other directives act first
|
||||||
|
priority: -1000,
|
||||||
|
|
||||||
// Two-way bind key, ngModel, and parameters
|
// Two-way bind key, ngModel, and parameters
|
||||||
scope: { key: "=", ngModel: "=", parameters: "=" }
|
scope: { key: "=", ngModel: "=", parameters: "=" }
|
||||||
};
|
};
|
||||||
|
@ -236,6 +236,9 @@ define(
|
|||||||
// Handle Angular's linking step
|
// Handle Angular's linking step
|
||||||
link: link,
|
link: link,
|
||||||
|
|
||||||
|
// May hide the element, so let other directives act first
|
||||||
|
priority: -1000,
|
||||||
|
|
||||||
// Two-way bind key and parameters, get the represented domain
|
// Two-way bind key and parameters, get the represented domain
|
||||||
// object as "mct-object"
|
// object as "mct-object"
|
||||||
scope: {
|
scope: {
|
||||||
|
@ -83,11 +83,12 @@ define(
|
|||||||
|
|
||||||
function populateElement(template) {
|
function populateElement(template) {
|
||||||
template(scope, function (innerClone) {
|
template(scope, function (innerClone) {
|
||||||
|
element.empty();
|
||||||
element.append(innerClone);
|
element.append(innerClone);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyTemplate(template) {
|
function applyTemplate(template, templateUrl) {
|
||||||
if (template) {
|
if (template) {
|
||||||
populateElement(template);
|
populateElement(template);
|
||||||
} else {
|
} else {
|
||||||
@ -99,7 +100,12 @@ define(
|
|||||||
if (templateUrl !== activeTemplateUrl) {
|
if (templateUrl !== activeTemplateUrl) {
|
||||||
if (templateUrl) {
|
if (templateUrl) {
|
||||||
addElement();
|
addElement();
|
||||||
self.load(templateUrl).then(applyTemplate);
|
self.load(templateUrl).then(function (template) {
|
||||||
|
// Avoid race conditions
|
||||||
|
if (templateUrl === activeTemplateUrl) {
|
||||||
|
applyTemplate(template);
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
removeElement();
|
removeElement();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user