-
Notifications
You must be signed in to change notification settings - Fork 43
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
Fixes issues with placeholder state and url; adds error property. #44
Conversation
e053b8a
to
2eccb5a
Compare
f066852
to
78358f7
Compare
I was testing this out and ran into a couple of problems: The !! in the following binding doesn't work: <img id="img" role="none" hidden$="[[!!sizing]]"> I added back in the computed property to fix it: <img id="img" role="none" hidden$="[[_computeImageVisibility(sizing)]]"> The following CSS rules do not work: :host([sizing]) #backdrop {
display: block;
}
:host([sizing]) #img {
display: none;
} Pretty sure sizing needs to be an attribute for this to work. I added the reflectToAttribute to fix it: sizing: {
type: String,
reflectToAttribute: true,
value: null
}, I'm not sure if that's the right thing to do. Actually, with the hidden properties working, I'm not sure the various CSS rules changing the display attribute are even needed. I can do a PR but I'm pretty new to this and don't know the procedure for a PR on another PR. |
Thanks for looking this over! IE10 doesn't pay attention to hidden and we still (mostly) support it so I'd say leave the CSS for that in for now; otherwise you're right, these rules should be redundant. Although this could be cleaner if replaced with: [hidden] {
display: none;
} Also, yup, looks like Making a PR to a PR is really easy: every PR is just asking to merge one branch into another, so all you have to do is make a new request to merge your branch into this one (bicknellr/state) rather than master. When you're comparing changes from your branch and are about to make a PR you'll see two dropdown menus: If you want to submit a PR with some changes, I'd be glad to take them! (Otherwise, I can address the things you've pointed out once @cdata is ready to review.) |
One more issue: The EncodeURI on backdropImage and placeholder will be a breaking change for many users (including me :). It will double encode an already encoded URI used as input. If there isn't a really good reason for it, I would leave it out. If not, it probably needs to be clearly documented that raw input is expected. |
I submited PR #48 to address the issues with hidden and display attributes. I left the EncodeURI as is. |
Yeah, you're right, expecting the input to be encoded beforehand is more reasonable (and is the behavior of the default img tag anyways). |
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
b91074f
to
3e4fb02
Compare
@opus1269 I merged your changes and rebased on master - this seems to have confused @googlebot. Could you reply and let it know that you're ok contributing these changes? |
I authored these commits. On Mon, Nov 30, 2015 at 12:38 PM googlebot [email protected] wrote:
|
Ok, well @googlebot seems to not be able to handle this, I've looked up that you signed it anyways so it should be alright. |
}, | ||
img.onload = function() { | ||
var resolvedSrc = Polymer.ResolveUrl.resolveUrl(this.src, this.ownerDocument.baseURI); | ||
if (img.src !== resolvedSrc) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be nice to refactor this into a protected method that lets you compare srcs. Something like..
if (this._matchesSrc(img.src)) return;
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll add this in.
<div id="placeholder" hidden$="[[_computePlaceholderVisibility(fade,loaded,preload)]]" class$="[[_computePlaceholderClassName(fade,loaded,preload)]]"></div> | ||
<content></content> | ||
<div id="sizedImgDiv" role="img" aria-label$="{{alt}}" hidden$="[[_computeBackdropHidden(sizing)]]"></div> | ||
<img id="img" alt$="{{alt}}" hidden$="[[_computeImgHidden(sizing)]]"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really nice.
However, one thing I hadn't considered is that this means the default case will be that this will be
<img alt="" src=...>
This means that unless the user specifies an alt
attribute, the image will be hidden from screen readers (won't show up at all, as if it's not there to begin with).
Is there some way to set the default value to be null
and judiciously add this attribute only if the alt
attribute on the host is non-null?
Similarly, if the user does set alt=""
on the host, #sizedImagDiv
should probably be aria-hidden
, to get the same effect.
(For extra credit, it would be great to set a placeholder aria-label
on #sizedImgDiv
in that case. For <img>
elements, screen readers do the job on their own if no alt
attribute is provided, but in this case it won't have enough information to do that since this isn't an <img>
. The usual fallback is the filename part of the src
.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So aria-label=""
doesn't hide an element from screen readers like alt=""
would?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope - with ARIA everything needs to be explicit. With native attributes there's a bunch of implicit stuff that goes on that you just kinda ... need to memorise. :\
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, updated again. I wrote some tests too but they're really implementation dependent. Is there any way to programmatically inspect the accessibility tree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't directly programmatically inspect the accessibility tree just yet - there are a couple of experimental APIs around but not really in any usable state for your purposes.
The Accessibility Developer Tools does have some utils for trying to work out the computed name and role of a particular element:
https://github.com/GoogleChrome/accessibility-developer-tools/blob/master/src/js/AccessibilityUtils.js#L626
https://github.com/GoogleChrome/accessibility-developer-tools/blob/master/src/js/Properties.js#L236
Obviously in this case you'd still need to look at the child nodes inside shadow DOM, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, this looks really great now! I love all the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nifty; @cdata can you take a look again?
4d0b237
to
0b1acb9
Compare
reflectToAttribute: true | ||
}, | ||
|
||
_imgDivARIALabel: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this isn't meant to be set from the outside. It's just part of a bug work-around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(gone now anyways)
@cdata one more time? |
+1 |
2 similar comments
+1 |
👍 |
_computeRequiresPreload: function() { | ||
return this.preload && !this.loaded; | ||
var pathComponents = (new URL(this._resolveSrc(this.src))).pathname.split("/"); | ||
return pathComponents[pathComponents.length - 1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fancy 💎
Small details, otherwise LGTM 👍 |
Fixes issues with placeholder state and url; adds error property.
Fixes #16, #23, #30, #32, #33, #36.