Skip to content

Allow graceful degradation into textarea when there's no JavaScript / support for code-input #134

@WebCoder49

Description

@WebCoder49

I'm thinking:

<code-input language="javascript" placeholder="JavaScript code, highlighted"><textarea data-code-input-fallback placeholder="JavaScript code, not highlighted">// This is a demo file
console.log("Hello, World!");
</textarea></code-input>

If this syntax (including the data-code-input-fallback) conflicts with anyone's usage so far I'll be incredibly surprised; if HTML is written inside a code-input and contains a textarea[data-code-input-fallback], the <s can be replaced with &lt;s.

Very little code: just detect the textarea, transfer its value to the code-input value if it's present, and transfer textareaSyncAttributes to the code-input if the code-input doesn't already have them. CSS must be updated to override invisible text in textarea[data-code-input-fallback] - maybe always make it black on white.

This is useful because code-input can be used with HTML forms and no extra JavaScript.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions