if (!window.initialized) {
window.initialized = true
window.data = {
name: 'Joe',
age: 34,
}
const originalAppend = Element.prototype.append
Element.prototype.append = function append(...args) {
originalAppend.apply(this, args)
return this
}
window.renderWithString = function renderWithString(data) {
document.body.insertAdjacentHTML('beforeend', `
<div><span>name: ${data.name}</span> - <span>age: ${data.age}</span></div>
`)
}
window.renderWithAppend = function renderWithAppend(data) {
document.body.append(
document.createElement('div').append(
document.createElement('span').append(
'name: '+data.name
),
' - ',
document.createElement('span').append(
'age: '+data.name
),
),
)
}
}