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

[Glimmer2] Fix class bindings #13337

Merged
merged 1 commit into from
May 6, 2016
Merged

[Glimmer2] Fix class bindings #13337

merged 1 commit into from
May 6, 2016

Conversation

asakusuma
Copy link
Contributor

Not sure this is correct way to get the class name out of the binding object.

@@ -1,5 +1,7 @@
import { tokenize } from 'simple-html-tokenizer';

let whitespace = new RegExp('( )+', 'g');
Copy link
Contributor

@krisselden krisselden Apr 15, 2016

Choose a reason for hiding this comment

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

const WHITESPACE = /\s+/;

The global flag isn't needed for split, neither is the group.

Copy link
Member

@stefanpenner stefanpenner Apr 15, 2016

Choose a reason for hiding this comment

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

@krisselden your example includes other things, space\tab\carriage return\new line\vert tab/form feed, which may or may not be expected.

I think the goal is one or more spaces which I think is more accurately expressed as

  • / +/
  • /[ ]+/ or to be clear we want one or more of a space

but ( )+ seems to imply capturing and g is global, both likely not the intent, and /\s+/ includes other chars, which may or not want to be matched.

@chadhietala
Copy link
Contributor

chadhietala commented Apr 15, 2016

I'm not sure if this the approach we want to take. After talking @wycats it seems like glimmer needs to expose a refineExpression hook in the environment to compliment refineStatement. This is so that statements don't need to "peek" inside to handle functionality like this. I'm currently trying to figure out how to add the refineExpression hook.

@homu
Copy link
Contributor

homu commented Apr 21, 2016

☔ The latest upstream changes (presumably #13372) made this pull request unmergeable. Please resolve the merge conflicts.

@asakusuma asakusuma force-pushed the g2-cb branch 2 times, most recently from ea31281 to 77f9814 Compare April 29, 2016 20:28
@asakusuma
Copy link
Contributor Author

Looks like saucelabs firefox is crapping out

Error: [init({"browserName":"firefox","version":"latest","platform":"","deviceName":"","device-orientation":"","tags":["Saucie","test"],"name":"Saucie tests","public":"public","build":"18176","tunnel-identifier":"18176.6","record-video":true})] The environment you requested was unavailable.

@asakusuma
Copy link
Contributor Author

Build is passing now

let syntax = HelperSyntax.fromSpec(['helper', ['-class'], [truthy], null]);
args.named.add('class', syntax);
} else if (falsy) {
let parts = prop.split('.');
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't you read the parts of the Ref syntax?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@chadhietala in this case the object returned from args.named.at('classBinding') only has type and value properties. There's no ref property.

@asakusuma
Copy link
Contributor Author

@rwjblue I just rebased and now the tests are failing because of a deprecation being thrown as an error.

Uncaught Error: `Ember.Binding` is deprecated. Consider using an `alias` computed property instead.

It's unclear to me if this is expected, and if so, does that mean that classBinding should not be implemented for glimmer?

Looks like this PR introduced the deprecation: #13424

@chadhietala
Copy link
Contributor

@asakusuma It needs to be implemented as Ember.Binding won't be removed till 3.0.0. https://github.com/emberjs/ember.js/pull/13424/files#diff-d50d2452ca8c5f57019c1974e6a3fb52R298

@rwjblue
Copy link
Member

rwjblue commented May 3, 2016

All tests for classBinding will have to expectDeprecation.

@asakusuma
Copy link
Contributor Author

asakusuma commented May 4, 2016

@chadhietala I think we were overcomplicating this. Updated PR is now a lot simpler. Let me know if this is not a public API, but seems public to me.

@krisselden
Copy link
Contributor

This is creating the binding in the wrong scope. It is supposed to be the template scope not the component. Unfortunately the test does not actually cover bindings, just static classes, but doing a quick search of github, this does seemed to be a used feature though undocumented and not tested.

let syntax;
if (args.named.has('class')) {
// If class already exists, merge
let classValue = args.named.at('class').value;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This currently won't work with helpers. If we need to support this, we'll need a way to generate a spec from a helper.

@rwjblue rwjblue merged commit 8f38585 into emberjs:master May 6, 2016
@rwjblue
Copy link
Member

rwjblue commented May 6, 2016

Thank you @asakusuma!

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

Successfully merging this pull request may close these issues.

7 participants