-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestrawdom.js
344 lines (332 loc) · 8.34 KB
/
testrawdom.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
(function () {
'use strict';
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var rawdom_cjs$1 = createCommonjsModule(function (module, exports) {
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var frag = function (...children) {
const documentFragment = document.createDocumentFragment();
for (let child of children) {
if (typeof child === 'string') {
documentFragment.appendChild(document.createTextNode(child));
}
else {
documentFragment.appendChild(child);
}
}
return documentFragment;
};
function isEventListener(attrName, attrValue) {
attrValue;
return attrName.substr(0, 2).toLowerCase() === 'on';
}
var addAttributes = function (el, attr = {}) {
for (let attrName in attr) {
if (!attr.hasOwnProperty(attrName)) {
continue;
}
const attrValue = attr[attrName];
if (isEventListener(attrName, attrValue)) {
const eventName = attrName.substr(2).toLowerCase();
el.addEventListener(eventName, attrValue);
continue;
}
el.setAttribute(attrName, attrValue);
}
};
function createElementWithAttributesAndChildren(tag, attr = {}, ...children) {
const el = document.createElement(tag);
addAttributes(el, attr);
el.appendChild(frag(...children));
return el;
}
var createElement = function (tag, attrOrChild = {}, ...children) {
if (attrOrChild instanceof HTMLElement || typeof attrOrChild === 'string') {
return createElementWithAttributesAndChildren(tag, {}, attrOrChild, ...children);
}
return createElementWithAttributesAndChildren(tag, attrOrChild, ...children);
};
var empty = function (el) {
while (el.lastChild) {
el.removeChild(el.lastChild);
}
};
const c = (tag) => createElement.bind(null, tag);
const a = c('a');
const abbr = c('abbr');
const address = c('address');
const article = c('article');
const aside = c('aside');
const audio = c('audio');
const b = c('b');
const bdi = c('bdi');
const bdo = c('bdo');
const blockquote = c('blockquote');
const body = c('body');
const button = c('button');
const canvas = c('canvas');
const caption = c('caption');
const cite = c('cite');
const code = c('code');
const colgroup = c('colgroup');
const data = c('data');
const datalist = c('datalist');
const dd = c('dd');
const del = c('del');
const details = c('details');
const dfn = c('dfn');
const dialog = c('dialog');
const div = c('div');
const dl = c('dl');
const dt = c('dt');
const em = c('em');
const fieldset = c('fieldset');
const figcaption = c('figcaption');
const figure = c('figure');
const footer = c('footer');
const form = c('form');
const h1 = c('h1');
const h2 = c('h2');
const h3 = c('h3');
const h4 = c('h4');
const h5 = c('h5');
const h6 = c('h6');
const head = c('head');
const header = c('header');
const hgroup = c('hgroup');
const html = c('html');
const i = c('i');
const iframe = c('iframe');
const ins = c('ins');
const kbd = c('kbd');
const keygen = c('keygen');
const label = c('label');
const legend = c('legend');
const li = c('li');
const main = c('main');
const map = c('map');
const mark = c('mark');
const math = c('math');
const menu = c('menu');
const meter = c('meter');
const nav = c('nav');
const noscript = c('noscript');
const object = c('object');
const ol = c('ol');
const optgroup = c('optgroup');
const option = c('option');
const output = c('output');
const p = c('p');
const picture = c('picture');
const pre = c('pre');
const progress = c('progress');
const q = c('q');
const rb = c('rb');
const rp = c('rp');
const rt = c('rt');
const rtc = c('rtc');
const ruby = c('ruby');
const s = c('s');
const samp = c('samp');
const script = c('script');
const section = c('section');
const select = c('select');
const slot = c('slot');
const small = c('small');
const span = c('span');
const strong = c('strong');
const style = c('style');
const sub = c('sub');
const summary = c('summary');
const sup = c('sup');
const svg = c('svg');
const table = c('table');
const tbody = c('tbody');
const td = c('td');
const template = c('template');
const textarea = c('textarea');
const tfoot = c('tfoot');
const th = c('th');
const thead = c('thead');
const time = c('time');
const title = c('title');
const tr = c('tr');
const u = c('u');
const ul = c('ul');
const varr = c('var');
const video = c('video');
const area = c('area');
const base = c('base');
const br = c('br');
const col = c('col');
const embed = c('embed');
const hr = c('hr');
const img = c('img');
const input = c('input');
const link = c('link');
const meta = c('meta');
const param = c('param');
const source = c('source');
const track = c('track');
const wbr = c('wbr');
exports.empty = empty;
exports.a = a;
exports.abbr = abbr;
exports.address = address;
exports.article = article;
exports.aside = aside;
exports.audio = audio;
exports.b = b;
exports.bdi = bdi;
exports.bdo = bdo;
exports.blockquote = blockquote;
exports.body = body;
exports.button = button;
exports.canvas = canvas;
exports.caption = caption;
exports.cite = cite;
exports.code = code;
exports.colgroup = colgroup;
exports.data = data;
exports.datalist = datalist;
exports.dd = dd;
exports.del = del;
exports.details = details;
exports.dfn = dfn;
exports.dialog = dialog;
exports.div = div;
exports.dl = dl;
exports.dt = dt;
exports.em = em;
exports.fieldset = fieldset;
exports.figcaption = figcaption;
exports.figure = figure;
exports.footer = footer;
exports.form = form;
exports.h1 = h1;
exports.h2 = h2;
exports.h3 = h3;
exports.h4 = h4;
exports.h5 = h5;
exports.h6 = h6;
exports.head = head;
exports.header = header;
exports.hgroup = hgroup;
exports.html = html;
exports.i = i;
exports.iframe = iframe;
exports.ins = ins;
exports.kbd = kbd;
exports.keygen = keygen;
exports.label = label;
exports.legend = legend;
exports.li = li;
exports.main = main;
exports.map = map;
exports.mark = mark;
exports.math = math;
exports.menu = menu;
exports.meter = meter;
exports.nav = nav;
exports.noscript = noscript;
exports.object = object;
exports.ol = ol;
exports.optgroup = optgroup;
exports.option = option;
exports.output = output;
exports.p = p;
exports.picture = picture;
exports.pre = pre;
exports.progress = progress;
exports.q = q;
exports.rb = rb;
exports.rp = rp;
exports.rt = rt;
exports.rtc = rtc;
exports.ruby = ruby;
exports.s = s;
exports.samp = samp;
exports.script = script;
exports.section = section;
exports.select = select;
exports.slot = slot;
exports.small = small;
exports.span = span;
exports.strong = strong;
exports.style = style;
exports.sub = sub;
exports.summary = summary;
exports.sup = sup;
exports.svg = svg;
exports.table = table;
exports.tbody = tbody;
exports.td = td;
exports.template = template;
exports.textarea = textarea;
exports.tfoot = tfoot;
exports.th = th;
exports.thead = thead;
exports.time = time;
exports.title = title;
exports.tr = tr;
exports.u = u;
exports.ul = ul;
exports.varr = varr;
exports.video = video;
exports.area = area;
exports.base = base;
exports.br = br;
exports.col = col;
exports.embed = embed;
exports.hr = hr;
exports.img = img;
exports.input = input;
exports.link = link;
exports.meta = meta;
exports.param = param;
exports.source = source;
exports.track = track;
exports.wbr = wbr;
});
var rawdom_cjs_2 = rawdom_cjs$1.a;
var rawdom_cjs_13 = rawdom_cjs$1.button;
var rawdom_cjs_35 = rawdom_cjs$1.h1;
var rawdom_cjs_52 = rawdom_cjs$1.li;
var rawdom_cjs_53 = rawdom_cjs$1.main;
var rawdom_cjs_102 = rawdom_cjs$1.ul;
document.body.appendChild(
rawdom_cjs_53(
rawdom_cjs_102(
rawdom_cjs_52(
rawdom_cjs_2(
{
href: 'https://xkcd.com',
target: '_blank',
rel: 'noopener noreferrer'
},
'xkcd comics'
)
),
rawdom_cjs_52(
rawdom_cjs_2(
{
href: 'http://phdcomics.com/',
target: '_blank',
rel: 'noopener noreferrer'
},
'phd comics'
)
)
),
rawdom_cjs_35('Click above links for humor'),
rawdom_cjs_13(
{
onclick: () => {alert('BUTTON CLICKED');}
},
'click here to alert'
)
)
);
}());