html-in-canvas-polyfill

Playground

Edit the HTML-in-Canvas example and run it. The preview draws live HTML into a canvas with the proposed API: <canvas content="drawable">, drawElementImage and the paint event. Click the drawn field and type.

Restores the original example and runs it. Copies a link that contains this code.

The body of the preview page.

Tab indents; Esc then Tab leaves the editor. Ctrl+Enter or ⌘+Enter runs.

Preview

Draws a dashed outline around every canvas of the preview. Your code can override it.

starting

Console

  1. No messages.

What runs

The preview loads the polyfill's core and engines bundles from this site, then your code. Where the browser has a complete native implementation, the polyfill steps aside and your code runs on the browser's own; the line above the preview says which. A dashed outline marks the canvas (Show canvas bounds); it is not part of your code. The effects and the plugins are not loaded: try them in the plugin gallery.

The sandbox

The preview is a sandboxed frame with an opaque origin: it cannot read this site's cookies or storage, open windows or dialogs, or submit forms. Images and fonts from another server are drawn only if that server allows cross-origin (CORS) reads. If your code stops responding, edit it and press Run, or press Reset.

Your code

It stays in your browser. Share puts it in the link's # fragment, which browsers do not send to the server. The editor's colours come from Prism, loaded from cdnjs; without it, the code shows in plain text. Tested in desktop Chrome, Firefox 155+ and Safari 27+.