Skip to content
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

fix(mjml-core): proper validation of mjml tag #2709

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions packages/mjml-document/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "mjml-document",
"description": "mjml-document",
"version": "4.14.1",
"main": "lib/index.js",
"files": [
"lib"
],
"repository": {
"type": "git",
"url": "git+https://github.com/mjmlio/mjml.git",
"directory": "packages/mjml-document"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/mjmlio/mjml/issues"
},
"homepage": "https://mjml.io",
"scripts": {
"clean": "rimraf lib",
"build": "babel src --out-dir lib --root-mode upward"
},
"dependencies": {
"@babel/runtime": "^7.14.6",
"lodash": "^4.17.21",
"mjml-core": "4.14.1"
},
"devDependencies": {
"@babel/cli": "^7.8.4",
"rimraf": "^3.0.2"
}
}

11 changes: 11 additions & 0 deletions packages/mjml-document/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { BodyComponent } from 'mjml-core'

export default class MjDocument extends BodyComponent {
static componentName = 'mjml'

static endingTag = false

render() {
return ''
}
}
Comment on lines +1 to +11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really happy with this solution here, body component expect to render something, it's just a hack at the end to make it work :/

I guess we could add something like a "mock-class" inside MJML just here to list mjml attributes + dependencies but it doesn't really need to have it's own package and should live inside mjml-core

2 changes: 2 additions & 0 deletions packages/mjml-preset-core/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
AccordionText,
AccordionTitle,
} from 'mjml-accordion'
import Document from 'mjml-document'
import Body from 'mjml-body'
import Head from 'mjml-head'
import HeadAttributes from 'mjml-head-attributes'
Expand All @@ -31,6 +32,7 @@ import Wrapper from 'mjml-wrapper'
import dependencies from './dependencies'

const components = [
Document,
Body,
Head,
HeadAttributes,
Expand Down
4 changes: 1 addition & 3 deletions packages/mjml-validator/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import dependencies, {
assignDependencies,
} from './dependencies'

const SKIP_ELEMENTS = ['mjml']

export const formatValidationError = ruleError

export { rulesCollection, registerRule }
Expand All @@ -17,7 +15,7 @@ export default function MJMLValidator(element, options = {}) {
const { children, tagName } = element
const errors = []

const skipElements = options.skipElements || SKIP_ELEMENTS
const skipElements = options.skipElements || []

if (options.dependencies == null) {
console.warn('"dependencies" option should be provided to mjml validator')
Expand Down