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

[BUGFIX beta] Remove attributes that are set to null or undefined. #10709

Merged
merged 1 commit into from
Mar 24, 2015

Conversation

dgeb
Copy link
Member

@dgeb dgeb commented Mar 23, 2015

This resolves a problem in the legacy bind-attr implementation in
which attributes would be set to null instead of being removed.
This led to spurious fetches for src attributes of img elements
and may have had other side effects.

[Fixes #10675]

@rwjblue
Copy link
Member

rwjblue commented Mar 23, 2015

This is somewhat related to the conversation we had at #10687 (comment).

@mixonic - r?

@mixonic
Copy link
Member

mixonic commented Mar 23, 2015

:-/ @dgeb So src is set using a property, since src is a property on document.createElement('img').

Can we add src to a list that already includes value, here: https://github.com/dgeb/ember.js/blob/bug-fix-10675/packages/ember-views/lib/attr_nodes/legacy_bind.js#L32

And include both null and an undefined in the values which are known to not actually be clearing? Instead both src and value expect to see '' for clearing.

At a later time, this should probably move to the dom helper.

@dgeb
Copy link
Member Author

dgeb commented Mar 23, 2015

@mixonic I might be misunderstanding you, but if I change:

  if (this.attrName === 'value' && value === null) {
    value = '';
  }

To:

  if ((this.attrName === 'value' || this.attrName === 'src') && value === null) {
    value = '';
  }

Then the src attribute is not cleared by simply setting its value to an empty string. It doesn't seem to be cleared without calling removeAttribute.

Note that value is set to null already if it's undefined.

Please let me know if I'm misunderstanding your suggestion.

@mixonic
Copy link
Member

mixonic commented Mar 23, 2015

@dgeb it won't make a request for the asset with '' though.

I'd prefer to not lean on removeAttribute when we normal deal with property values for value and src. The inconsistency sits uncomfortably with me, I'd rather set a neutral property value. I'm on IRC if you want to kick it around.

@dgeb
Copy link
Member Author

dgeb commented Mar 23, 2015

@mixonic - gotcha - will revise this PR.

This resolves a problem in the legacy `bind-attr` implementation in
which `src` attributes would be set to `null` instead of being
removed or cleared. This led to spurious fetches for invalid assets.

[Fixes emberjs#10675]
@dgeb
Copy link
Member Author

dgeb commented Mar 23, 2015

@mixonic @rwjblue revised - please review.

@rwjblue
Copy link
Member

rwjblue commented Mar 24, 2015

LGTM

rwjblue added a commit that referenced this pull request Mar 24, 2015
[BUGFIX beta] Remove attributes that are set to `null` or `undefined`.
@rwjblue rwjblue merged commit 4cd4c7c into emberjs:master Mar 24, 2015
@rwjblue
Copy link
Member

rwjblue commented Mar 26, 2015

Pulling into beta (need commit prefix next time though)....

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.

Image src Always Fetched, Even When Guarded
3 participants