Ghost: Data attributes are stripped on AMP page (data-)

Created on 14 Mar 2018  路  2Comments  路  Source: TryGhost/Ghost

HTML attributes starting data- are stripped from HTML on AMP page.

Example:

<td data-label="some-attribute">
    Content
</td>

I found in Docs of AMP page (link to docs):

In addition to a whitelist of specific attributes for each tag, all AMP tags can use any of the attributes white-listed under $GLOBAL_ATTRS; all attributes with a prefix of "data-" are also whitelisted.

I am using data attributes inside tables to adapt it on mobile devices with CSS.

Ghost Version: 1.21.1

good first issue help wanted server / core

Most helpful comment

Hi @AileenCGN,

I've opened up a PR with (hopefully) the fix - https://github.com/TryGhost/Ghost/pull/9501

I've been waiting for a smaller fix to need doing to get me settled into the Ghost codebase so hopefully I've done this correctly!

All 2 comments

Thanks for the report. This should be a super simple fix here: https://github.com/TryGhost/Ghost/blob/master/core/server/apps/amp/lib/helpers/amp_content.js#L44

PRs welcome!

Hi @AileenCGN,

I've opened up a PR with (hopefully) the fix - https://github.com/TryGhost/Ghost/pull/9501

I've been waiting for a smaller fix to need doing to get me settled into the Ghost codebase so hopefully I've done this correctly!

Was this page helpful?
0 / 5 - 0 ratings