feat(mjml-social): add border attribute to mj-social-element#3105
Open
danfitz36 wants to merge 1 commit into
Open
feat(mjml-social): add border attribute to mj-social-element#3105danfitz36 wants to merge 1 commit into
danfitz36 wants to merge 1 commit into
Conversation
Email accessibility tooling (Email on Acid, Litmus) flags <img> tags in social blocks for missing border attributes. mj-image already supports a `border` attribute that lands as CSS on the rendered <img>; mj-social-element did not, leaving no way to set or default it without copying the rendered HTML out by hand. Adds `border` to mj-social-element with default `0` (matching mj-image's default). Also exposes `border` on the mj-social parent and cascades it through getSocialElementAttributes so a single border declaration applies to every child element. Element-level borders still take precedence over the cascaded parent value. README attribute tables updated for both components. Fix mjmlio#2466.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2466.
Email accessibility tooling (Email on Acid, Litmus) flags
<img>tags in social blocks for missingborderattributes.mj-imagealready supports aborderattribute that renders as CSS on the resulting<img>;mj-social-elementdid not, leaving no way to set or default it without copying the rendered HTML out by hand.Changes
packages/mjml-social/src/SocialElement.jsborder: 'string'toallowedAttributesborder: '0'todefaultAttributes(matchesmj-image's default)border: this.getAttribute('border')to theimgstyles ingetStyles()packages/mjml-social/src/Social.jsborder: 'string'toallowedAttributesborderto the cascade list ingetSocialElementAttributesso a single declaration onmj-socialapplies to every child. Element-level borders still take precedence.packages/mjml-social/README.mdborderrows in both attribute tablespackages/mjml/test/social-border.test.js(new)0on every element, explicit element override, parent cascade, and element-overrides-cascadeSample rendered output
With:
The three
<img>tags emit:style="border:1px solid #ccc;border-radius:3px;display:block;"(cascaded)style="border:2px solid red;border-radius:3px;display:block;"(element override)style="border:1px solid #ccc;border-radius:3px;display:block;"(cascaded)Verification
yarn build✓ all packagesyarn test✓ 74 → 78 (the 4 new cases)