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

cleanup how component id attr is set #16561

Merged
merged 1 commit into from
Jun 8, 2018
Merged

Conversation

bekzod
Copy link
Contributor

@bekzod bekzod commented Apr 21, 2018

there is asymmetry how id attributes are set, this fixes it

}

if (seen.indexOf('id') === -1) {
operations.setAttribute('id', PrimitiveReference.create(component.elementId), true, null);
Copy link
Contributor Author

@bekzod bekzod Apr 21, 2018

Choose a reason for hiding this comment

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

@bekzod bekzod force-pushed the fix-assymetry branch 6 times, most recently from 4280e9f to bbc29ca Compare April 21, 2018 14:42
@@ -73,27 +73,26 @@ function applyAttributeBindings(
component: Component,
operations: ElementOperations
) {
let seen: string[] = [];
let seen: Set<String> = new Set();
Copy link
Contributor

Choose a reason for hiding this comment

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

I doubt Set to be actually faster for less than < 10 attributes and most elements don't have that many.

We should definitely try to test this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

such thought crossed my mind too, so reverting this changes :P

Copy link
Contributor

@krisselden krisselden left a comment

Choose a reason for hiding this comment

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

Can you add a test and label as a bugfix? I'm not sure what you are fixing here.

@bekzod bekzod changed the title cleanup/fix how component id attr is set cleanuphow component id attr is set Jun 7, 2018
@bekzod bekzod changed the title cleanuphow component id attr is set cleanup how component id attr is set Jun 7, 2018
@bekzod
Copy link
Contributor Author

bekzod commented Jun 7, 2018

not fixing here anything just avoiding calling operations.setAttribute('id'..... twice, initially thought that there is bug here because operations.setAttribute('id' was called twice @krisselden

@rwjblue
Copy link
Member

rwjblue commented Jun 8, 2018

The changes here seem good, but I did want to point out that ComponentOperations (the thing called operations in didCreateElement) is specifically built to absorb the duplicate attribute setting in a "last one wins" strategy, and it avoids doing the DOM manipulation more than once.

@rwjblue rwjblue merged commit 0220419 into emberjs:master Jun 8, 2018
@bekzod bekzod deleted the fix-assymetry branch June 8, 2018 13:50
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.

3 participants