Skip to content

Commit

Permalink
ui: Move get-component-factory into utils/dom
Browse files Browse the repository at this point in the history
  • Loading branch information
John Cowen committed Nov 8, 2018
1 parent 1b9a994 commit 00663a2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions ui-v2/app/services/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand All @@ -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) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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';
Expand Down

0 comments on commit 00663a2

Please sign in to comment.