Issue #2844💬 AnsweredOpened June 20, 2020by akashdesale980 reactions

If we give "<input data-gjs-type="myInput" type="text" required/>" this html string to setComponents, it sets it like "<input data-gjs-type="myInput" type="text" required=""/>" in code manager

快速解答by artf

For now, you can avoid it only by adding the Component Definition in this way but I'll update the HTML parser in the next release to handle this properly

Read full answer below ↓

Question

editor.setComponents("html stiring"), method which takes html string as an input and sets that code in the html section in the Code Manager

if we pass ,<input data-gjs-type="myInput" type="text" required/>" to editor.setComponents,

then its output will be "<input data-gjs-type="myInput" type="text" required=""/>

If you see setComponents is adding extra strings to required tag , it happens with every single attribute like autofocus, disabled and all othe single boolean tags?

is there any way to avoid this?

Answers (1)

artfJune 25, 2020

For now, you can avoid it only by adding the Component Definition in this way

editor.addComponents({ 
    tagName: 'input',
    attributes: { type: 'text', required: true }
})

but I'll update the HTML parser in the next release to handle this properly

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.