Quick Edit generates invalid html markup, even for users (e.g. Anonymous) who don't have access to in-line edit.

Specifically, W3C validation script complains about a div inside h1 which is invalid and also about the unknown data-quickedit-field-id attribute:

<div id="content" class="column"><div class="section">
            <a id="main-content"></a>
                    <h1 class="title" id="page-title">
          <div data-quickedit-field-id="node/1/title/und/full">Site name</div>        </h1>
                          <div class="tabs">
                  </div>
                          <div class="region region-content">
    <div id="node-1" class="node node-page node-full clearfix" data-quickedit-entity-id="node/1">
  <div class="content clearfix">
    <div class="field field-name-body field-type-text-with-summary field-label-hidden" data-quickedit-field-id="node/1/body/und/full"><div class="field-items"><div class="field-item even"><p>Welcome to our page!</p>

I understand that this is necessary in order for Quick Edit to work, but I think it would be better if this markup was added only for users that have access to in-line edit. This way, most of the site would still appear valid to W3C validation engine, Google bots etc.

Comments

yannisc’s picture

Status: Active » Needs review
StatusFileSize
new2.11 KB

Here is a patch that does just that: Adds the Quick Edit markup only for users that have access to in-place editing. Drupal is HTML valid again.

I tested and seems to work, but further testing is needed for sure, as I don't know what other implications this might have.

Status: Needs review » Needs work
yannisc’s picture

The test failed, because the testbot checks as anonymous user. I don't know how to fix the test. Should we make the test check as registered user (and how) or should we remove this test?

frazac_naba’s picture

I quote the problem.
Here my code output for anonymous user.
Thanks for working on it

<div id="page-title" class="contextual-region block clearfix block-core">
<div data-contextual-id="block:block=cpark_page_title:langcode=it"></div>
<h1 class="js-quickedit-page-title"><span property="schema:name" data-quickedit-field-id="node/1/title/it/full">Creatività in testa</span>
</h1>
</div>
jonasdk’s picture

I guess this is solved here https://www.drupal.org/node/2528498

devin carlson’s picture

Title: Quick Edit generates invalid markup, even for users who don't have access to it. » Only emit Quick Edit data- attributes when actually necessary
Version: 7.x-1.1 » 7.x-1.x-dev
Category: Bug report » Task
Status: Needs work » Needs review
StatusFileSize
new6.12 KB

Thanks for the patch!

I've updated the tests to verify that the markup is only output for privileged users and changed the requirements check to require anonymous users be granted the ability to quick edit in order to perform the compatibility testing.

devin carlson’s picture

Status: Needs review » Fixed

Tested #6 and committed to Quick Edit 7.x-1.x.

  • Devin Carlson committed 4fa4dd2 on 7.x-1.x authored by yannisc
    Issue #2389677 by yannisc, Devin Carlson: Only emit Quick Edit data-...
yannisc’s picture

Great News! Thanks!!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.