Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check config for defaults #52

Merged

Conversation

sbatson5
Copy link
Contributor

@sbatson5 sbatson5 commented Mar 14, 2018

What's in this PR?

Should address the comment on this thread: #31 (comment)

I ran into this issue as well. The README implies that by adding the EmberHammertime hash to your config/environment you can set defaults. However, the mixin does not look at the consuming app's config and overwrite the defaults. This PR would allow the user to specify which defaults they want.

@scanieso
Copy link

This LGTM! 🚀

@RobbieTheWagner
Copy link
Member

@sbatson5 the config stuff should work. What issues are you experiencing?

@RobbieTheWagner
Copy link
Member

Ah, I guess the issue is the config values work when you don't use the mixin, but the mixin does not?

@eriktrom
Copy link
Member

the config stuff should work. What issues are you experiencing?

I think he wants to configure it from environment.js from within the app. If that's not it then not sure either...


const FocusableInputTypes = ['button', 'submit', 'text', 'file'];
// Set this to `false` to not apply the styles automatically to elements with an `action`
const TouchActionOnAction = true;
const TouchActionOnAction = (typeof defaults.touchActionOnAction == 'undefined') ? true : defaults.touchActionOnAction;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use typeof, and use === e.g.:

const TouchActionOnAction = (defaults.touchActionOnAction === undefined) ? true : defaults.touchActionOnAction;

@@ -38,7 +41,7 @@ export default Mixin.create({
ignoreTouchAction: false,

init() {
this._super();
this._super(...arguments);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove ...arguments - this is a very hot code path - hat tip to @runspired for noticing this in a previous round where i did the same thing. U don't need it here, nor do u want it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eriktrom why do we not want this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runspired told me to remove it when i updated this file last year - he said that ...arguments slows things down(which is true, i later found out when writing an unrelated algo), and that its not needed either in this case (b/c its a mixin? that part im not sure 'why' but i trust him on it 👍)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't heard of spread arguments being a perf hit before. Or is it just because of the babel transpilation? Happy to revert this back however as it shouldn't make a difference.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

babel transpilation per this discussion (of this file) 2 years ago though, hazy memory - #27 (comment), didn't quote it quite right, actually quoted this instead (a couple comments down) - #27 (comment)

(side note per my comment of my more recent encounter with passing ...arguments to a helper fn, inside an O(n) loop, perf_hooks caught it, i have not dug deeper, it was pretty recent finding, passing named args manually fixed it)

hope that clarifies things - for both of us now haha

// The actual style string that is applied to the elements. You can tweak this if you want something different.
const TouchActionProperties = 'touch-action: manipulation; -ms-touch-action: manipulation; cursor: pointer;';
const TouchActionProperties = defaults.touchActionProperties || 'touch-action: manipulation; -ms-touch-action: manipulation; cursor: pointer;';
Copy link
Member

@eriktrom eriktrom Mar 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a corresponding AST transform that we would want to line up with this. Either remove configuration of this, or make that use the same configuration passed in from the apps environment.js. Otherwise styles will be out of sync depending on whether the element is dynamic(rendered by glimmer vm) or static (rendered by browser as normal html tag). We want them to be the same in both cases.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The app config is already used in that stuff, just not in the mixin, I think.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah - i don't know if ember-get-config will pass through its options to the index.js file where we forward those options to the AST parser... or how to reconcile that.... but we shouldn't allow native link or button elements to have different css classes than ember components (like link-to) as that'll cause an inconsistent experience for devs (unless they're completely aware of touch-action css property, which is funky to say the least)

I'll check this as reviewed by me, but this issue in particular, I think we should ensure is right before merging...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eriktrom we're already consuming the app config in index.js here https://github.com/html-next/ember-hammertime/blob/master/index.js#L55.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh - yes thank you. looks like this will work out then using ember-get-config for the mixin, and that code for the ast parser.. config set once in environment.js. nice

(double rainbow, it does exist!)

Copy link
Member

@eriktrom eriktrom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving final approval to @rwwagner90

@RobbieTheWagner
Copy link
Member

I think this should work. Going to merge.

@RobbieTheWagner RobbieTheWagner merged commit 825e7e1 into html-next:master Mar 14, 2018
@RobbieTheWagner
Copy link
Member

Thanks @sbatson5!

@eriktrom
Copy link
Member

ps @sbatson5 - double thanks never hurts - nice job fixing this issue - its been outstanding for a good long while, appreciate it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants