Updated: Comment #N
Problem/Motivation
we dont use the id in Drupal unless its absolutely nessesary - its a pita for frontenders to work with & is unessasary
markupelements that needs a javascript behaviour must be prefixed with js- class to make it clear for the themer as stated here
https://drupal.org/node/1887918#separate-concerns or even better become a data-xxx so the css masters by accident removes the js-foo "cause its not doing anything"
Proposed resolution
remove the id="progress" from the template use a data-foo instead
before:
<div id="progress" class="progress">
{% if label %}
<div class="progress__label">{{ label }}</div>
{% endif %}
<div class="progress__track"><div class="progress__bar" style="width: {{ percent }}%"></div></div>
<div class="progress__percentage">{{ percent }}%</div>
<div class="progress__description">{{ message }}</div>
</div>
after:
<div class="progress" data-drupal-progress>
{% if label %}
<div class="progress__label">{{ label }}</div>
{% endif %}
<div class="progress__track"><div class="progress__bar" style="width: {{ percent }}%"></div></div>
<div class="progress__percentage">{{ percent }}%</div>
<div class="progress__description">{{ message }}</div>
</div>
Remaining tasks
test it
User interface changes
none
API changes
none
Related Issues
none
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | core-markup-progress-2091971-19.patch | 934 bytes | nod_ |
Comments
Comment #1
tlattimore commentedOh my.
id="progress" class="progress"- that is just dumb in my opinion. The proposed solution is much cleaner.Comment #2
nod_and use a data- attribute for the JS, also, tag.
Comment #3
dbazuin commentedI agree sounds perfect. Let's do it.
Comment #4
mortendk commentedSo were talking about ripping out class="js-progress" and instead add it in as a data-xx
that sounds even better so its completely seperated
Comment #5
nod_<div class="progress" data-drupal-progress>then assign to me :)Comment #6
dbazuin commentedShould that not be
Comment #6.0
dbazuin commentedUpdated issue summary.
Comment #7
mortendk commentedupdated the info but cant assign it to nod_ ?
can i haz epic power ?
Comment #8
nod_Could be, but then
data-drupalwill end up with completely unpredictable values and it'll be a mess when it's used for the message area and this or that.We just need the data attribute to "tag" a "tag", we don't need a value. It also means that the js selector becomes
'[data-drupal="progress"]'instead of the much nicer'[data-drupal-progress]'.So, no :)
Comment #9
nod_@mortendk, once the twig patch is done and I just need to fix the JS :)
Comment #10
nod_Actually, that's even simpler. This template is only used on non-js pages. We got the equivalent more or less hardcoded in the JS.
So this patch has no JS impact and doesn't need any data attribute. You can just remove the progress id and all will be well.
Comment #11
dbazuin commentedSo you would have used a data attribute without giving it a value?
Hmm hell why not :-)
Comment #11.0
dbazuin commentedUpdated issue summary.
Comment #12
katzillaI will have a look at this...
Comment #13
katzillaSimply removing the ID did not do the trick, because batch.js was also picking the ID from progress. Changed this to data-attribute now. Please review.
Comment #14
nod_Can you remove the div from the selector? Down the line we might end up using the progress element and it'd be a shame to break the js just beacuse of that. Thanks :)
Comment #15
nod_Comment #16
rainbowarrayWorking on a patch to take the div out of the selector.
Comment #17
rainbowarrayHere's a patch update with the div removed from the selector.
Comment #18
nod_Perfect, thanks!
Comment #19
nod_This is a reroll because the indentation standard changed for JavaScript files. No need for commit credit because of this reroll.
Comment #21
rainbowarrayI ran the render test that failed on my local dev with the patch applied, and the test passed. So, setting testbot to rerun this.
Comment #22
rainbowarray19: core-markup-progress-2091971-19.patch queued for re-testing.
Comment #23
rainbowarrayTests passed, good to go?
Comment #24
droplet commentedComment #25
alexpottCommitted e044708 and pushed to 8.x. Thanks!
Comment #27
alimac commentedMinor tag cleanup - please ignore.