diff --git a/ui-v2/app/services/dom.js b/ui-v2/app/services/dom.js index 471089c4ff82..ae88e0f5a063 100644 --- a/ui-v2/app/services/dom.js +++ b/ui-v2/app/services/dom.js @@ -9,13 +9,13 @@ import qsaFactory from 'consul-ui/utils/dom/qsa-factory'; // see if its possible to standardize import sibling from 'consul-ui/utils/dom/sibling'; import closest from 'consul-ui/utils/dom/closest'; +import getComponentFactory from 'consul-ui/utils/dom/get-component-factory'; -// TODO: Move to utils/dom -import getComponentFactory from 'consul-ui/utils/get-component-factory'; +// events import normalizeEvent from 'consul-ui/utils/dom/normalize-event'; import createListeners from 'consul-ui/utils/dom/create-listeners'; - import clickFirstAnchorFactory from 'consul-ui/utils/dom/click-first-anchor'; + // ember-eslint doesn't like you using a single $ so use double // use $_ for components const $$ = qsaFactory(); @@ -27,13 +27,11 @@ export default Service.extend({ this._super(...arguments); $_ = getComponentFactory(getOwner(this)); }, - closest: closest, - sibling: sibling, // TODO: should this be here? Needs a better name at least clickFirstAnchor: clickFirstAnchor, - normalizeEvent: function() { - return normalizeEvent(...arguments); - }, + closest: closest, + sibling: sibling, + normalizeEvent: normalizeEvent, listeners: createListeners, root: function() { return get(this, 'doc').documentElement; @@ -48,6 +46,8 @@ export default Service.extend({ return context.getElementByTagName(name); }, elements: function(selector, context) { + // don't ever be tempted to [...$$()] here + // it should return a NodeList return $$(selector, context); }, element: function(selector, context) { diff --git a/ui-v2/app/utils/get-component-factory.js b/ui-v2/app/utils/dom/get-component-factory.js similarity index 100% rename from ui-v2/app/utils/get-component-factory.js rename to ui-v2/app/utils/dom/get-component-factory.js diff --git a/ui-v2/tests/unit/utils/get-component-factory-test.js b/ui-v2/tests/unit/utils/dom/get-component-factory-test.js similarity index 90% rename from ui-v2/tests/unit/utils/get-component-factory-test.js rename to ui-v2/tests/unit/utils/dom/get-component-factory-test.js index 16be5c677eb3..bbac4560457e 100644 --- a/ui-v2/tests/unit/utils/get-component-factory-test.js +++ b/ui-v2/tests/unit/utils/dom/get-component-factory-test.js @@ -1,7 +1,7 @@ -import getComponentFactory from 'consul-ui/utils/get-component-factory'; +import getComponentFactory from 'consul-ui/utils/dom/get-component-factory'; import { module, test } from 'qunit'; -module('Unit | Utility | get component factory'); +module('Unit | Utility | dom/get component factory'); test("it uses lookup to locate the instance of the component based on the DOM element's id", function(assert) { const expected = 'name';