Created
April 12, 2015 02:08
-
-
Save joncasey/53f3f73a8b5969870866 to your computer and use it in GitHub Desktop.
Scrape HTML spec for list of elements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://www.w3.org/html/wg/drafts/html/master/index.html#elements-1 | |
// http://www.w3.org/TR/html/index.html#elements-1 | |
var events = document.querySelector('table#ix-event-handlers').tBodies[0].rows | |
var elements = document.querySelector('table').tBodies[0].rows | |
var spec = {} | |
Array.prototype.forEach.call(elements, function (tr) { | |
var tags = tr.cells[0].textContent.replace(/\s/g, '').split(',') | |
var attr = tr.cells[5].textContent.replace(/\s/g, '').trim().replace(/globals;?/, '').replace(/;/g, ' ') | |
tags.forEach(function (tag) { | |
spec[tag] = attr | |
}) | |
}) | |
spec['*on'] = [] | |
Array.prototype.forEach.call(events, function (tr) { | |
spec['*on'].push(tr.cells[0].textContent.trim().replace(/^on/, '')) | |
}) | |
// http://www.w3.org/TR/html/dom.html#global-attributes | |
spec['*'] = 'accesskey class contenteditable dir hidden id lang spellcheck style tabindex title translate' | |
spec | |
//document.body.appendChild(document.createElement('pre')).textContent = JSON.stringify(spec, 0, ' ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment