Skip to content

Commit 3624847

Browse files
committed
review
1 parent 0dedf8e commit 3624847

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

js/interactive-examples.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function createOutput(output) {
1818

1919
async function main() {
2020
const buffer = [];
21-
const {ccall} = await phpBinary({
21+
const { ccall } = await phpBinary({
2222
print(data) {
2323
if (!data) {
2424
return;
@@ -34,27 +34,28 @@ async function main() {
3434
console.log("PHP wasm %s loaded.", ccall("phpw_exec", "string", ["string"], ["phpversion();"]));
3535
let lastOutput = null
3636

37-
document.querySelectorAll('.example').forEach((example) => {
38-
const button = document.createElement('button');
39-
const phpcode = example.querySelector('.phpcode');
37+
document.querySelectorAll('.example').forEach((example) => {
38+
const button = document.createElement('button');
39+
button.setAttribute('type', 'button')
40+
const phpcode = example.querySelector('.phpcode');
4041

4142
const code = phpcode.querySelector('pre code')
4243
code.setAttribute('contentEditable', true)
4344

44-
button.innerText = 'Run code';
45-
button.onclick = function() {
45+
button.innerText = 'Run code';
46+
button.onclick = function() {
4647
if (lastOutput && lastOutput.parentNode) {
47-
lastOutput.parentNode.removeChild(lastOutput)
48+
lastOutput.remove()
4849
}
4950

5051
ccall("phpw_run", null, ["string"], ['?>' + phpcode.innerText]);
5152
lastOutput = createOutput(buffer.join(''))
5253
phpcode.parentNode.appendChild(lastOutput);
5354
buffer.length = 0;
54-
};
55+
};
5556

56-
phpcode.parentNode.insertBefore(button, phpcode);
57-
});
57+
phpcode.before(button);
58+
});
5859

5960
}
6061

0 commit comments

Comments
 (0)