[Layout] Don't use class name to query by id

...since ids may be invalid class names. Instead, use a data attribute. Fixes #1846
This commit is contained in:
Victor Woeltjen 2017-12-20 13:32:07 -08:00
parent fcef4274e5
commit b54ee2257e
3 changed files with 5 additions and 4 deletions

View File

@ -36,7 +36,8 @@
ng-style="{ 'background-size': '100% ' + controller.getGridSize() [1] + 'px' }"></div> ng-style="{ 'background-size': '100% ' + controller.getGridSize() [1] + 'px' }"></div>
</div> </div>
<div class="abs frame t-frame-outer child-frame panel s-selectable s-moveable s-hover-border {{childObject.getId() + '-' + $id}} t-object-type-{{ childObject.getModel().type }}" <div class="abs frame t-frame-outer child-frame panel s-selectable s-moveable s-hover-border t-object-type-{{ childObject.getModel().type }}"
data-layout-id="{{childObject.getId() + '-' + $id}}"
ng-class="{ 'no-frame': !controller.hasFrame(childObject), 's-drilled-in': controller.isDrilledIn(childObject) }" ng-class="{ 'no-frame': !controller.hasFrame(childObject), 's-drilled-in': controller.isDrilledIn(childObject) }"
ng-repeat="childObject in composition" ng-repeat="childObject in composition"
ng-init="controller.selectIfNew(childObject.getId() + '-' + $id, childObject)" ng-init="controller.selectIfNew(childObject.getId() + '-' + $id, childObject)"

View File

@ -515,7 +515,7 @@ define(
LayoutController.prototype.selectIfNew = function (selector, domainObject) { LayoutController.prototype.selectIfNew = function (selector, domainObject) {
if (domainObject.getId() === this.droppedIdToSelectAfterRefresh) { if (domainObject.getId() === this.droppedIdToSelectAfterRefresh) {
setTimeout(function () { setTimeout(function () {
$('.' + selector)[0].click(); $('[data-layout-id="' + selector + '"]')[0].click();
delete this.droppedIdToSelectAfterRefresh; delete this.droppedIdToSelectAfterRefresh;
}.bind(this), 0); }.bind(this), 0);
} }

View File

@ -475,11 +475,11 @@ define(
); );
var childObj = mockDomainObject("d"); var childObj = mockDomainObject("d");
var testElement = $("<div class='some-class'></div>"); var testElement = $("<div data-layout-id='some-id'></div>");
$element.append(testElement); $element.append(testElement);
spyOn(testElement[0], 'click'); spyOn(testElement[0], 'click');
controller.selectIfNew('some-class', childObj); controller.selectIfNew('some-id', childObj);
jasmine.Clock.tick(0); jasmine.Clock.tick(0);
expect(testElement[0].click).toHaveBeenCalled(); expect(testElement[0].click).toHaveBeenCalled();