webcontainer-dom
v1.0.2
Published
DOM access for WebContainers
Downloads
10
Readme
webcontainer-dom
DOM access for WebContainers
Methods
createElement
- adds element
Usage
index.js (in WebContainer):
const express = require('express');
const wcd = require('webcontainer-dom');
const app = express();
let dom = wcd(app);
app.use(express.static(__dirname));
dom.events.on('connect', (document) => {
document('createElement')('h1', {
innerText: 'Text 2',
style: {
color: 'red'
}
});
})
app.listen(8080);
index.html (in WebContainer):
<body>
<script src="./node_modules/webcontainer-dom/dist/wcd.js"></script>
<h1> Text 1 </h1>
</body>
index.html (actual webpage):
<!DOCTYPE HTML>
<html>
<body>
<script src="./node_modules/webcontainer-dom/dist/wcd-web.js"></script>
<script src="webcontainerCode.js"></script>
</body>
</html>