{"id":18860581,"url":"https://github.com/joewalker/serverdom","last_synced_at":"2026-02-09T01:30:17.663Z","repository":{"id":1081685,"uuid":"927684","full_name":"joewalker/serverdom","owner":"joewalker","description":"A browser compatible DOM for use with CommonJS / Node","archived":false,"fork":false,"pushed_at":"2010-09-21T23:09:00.000Z","size":100,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-30T20:23:07.332Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joewalker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-09-21T13:23:02.000Z","updated_at":"2012-12-15T05:57:22.000Z","dependencies_parsed_at":"2022-08-16T12:00:23.757Z","dependency_job_id":null,"html_url":"https://github.com/joewalker/serverdom","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joewalker%2Fserverdom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joewalker%2Fserverdom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joewalker%2Fserverdom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joewalker%2Fserverdom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joewalker","download_url":"https://codeload.github.com/joewalker/serverdom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239800487,"owners_count":19699128,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T04:25:55.729Z","updated_at":"2026-02-09T01:30:17.574Z","avatar_url":"https://github.com/joewalker.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nAbout ServerDOM\n===============\n\n**Version**: 0.1 (21 September 2010)  \n**Author**: Joe Walker [ joe at getahead dot org ]  \n**License**: Apache v2  \n\nServerDOM is an implementation of the DOM in JavaScript that lives on the server\nrather than in the browser. ServerDOM uses tautologistics\n[node-htmlparser](http://github.com/tautologistics/node-htmlparser) to do the\nnasty work of HTML parsing.\n\n\nWhy?\n----\n\nServer-side JavaScript brings with it the promise of being able to share logic\nbetween the client and the server. It's nice to be able to write your code only\nonce.\n\nHowever this is tricky with presentation logic, which often requires a DOM to\nwork against. Enter ServerDOM to provide a minimalist browser environment so\nyou can do progressive enhancement type things without writing everything twice.\n\n\nWhat is the Roadmap?\n--------------------\n\nIf there's not much interest, the the roadmap ends here, because it's currently\ngood enough for me, but if people like it then we can probably sort out some\nreleases like \"Supports JQuery v1.4\", \"Supports DOM levels 0-3\" and so on. I\nwill be relying on help making it better though.\n\n\nHow do I get started?\n---------------------\n\nStep 1: Install [Node](http://nodejs.org/)\n\nStep 2: Install and use ServerDOM:\n\n    $ git clone git@github.com:joewalker/serverdom.git\n    Initialized empty Git repository in /.../serverdom/.git/\n    [blah blah]\n    $ cd serverdom\n    $ git clone http://github.com/tautologistics/node-htmlparser.git\n    Initialized empty Git repository in /.../serverdom/node-htmlparser/.git/\n    [blah blah]\n    $ node test/domtest.js\n    completed\n    $ vi test/domtest.js\n    \"I see! It works like a browser DOM, but you start with 'new Document(...)'\"\n\nTo check that dom/js works in the same way as the browser, just load\n`test/test.html` into your browser. It will run the test suite against the a\nreal DOM. The results should be the same.\n\n\nHow good is it?\n---------------\n\nJust good enough for my needs at the moment, which is to say, very probably\nnot good enough for yours. It's a good way to covering most of the obvious stuff\nbut it's a long way from being a full browser mock-up.\n\n\nHow long before it's complete?\n------------------------------\n\nIt's probably not possible to write a full mock browser in pure JavaScript.\nFor example, several browsers have a fake document.all that appears to not\nexist until you use it, and then it magically works\n\n    if (!document.all) { console.log('missing all'); } // missing all\n    console.log(document.all.someId);                  // debugs an element\n\nMaybe there's a smart way of doing this, but the point remains, trying to\nreplicate the full browser in pure JavaScript is probably a fools errand.\n\n\nDoesn't that render ServerDOM pointless?\n----------------------------------------\n\nIt means that you probably can't use ServerDOM to do unit tests. We can't hope\nto mock the full insanity of the browser environment, but we can use it for the\nmore idealistic world of replicating mailable view logic. That is to say, if you\nhave some presentation logic that uses the mad document.all behaviour (*) then\nyou can still use ServerDOM, but by fixing your script.\n\n(* I know why document.all behaves the way it does - sometimes it pays to\npretend to be mad if you're dealing with someone that expects insanity - however\nthat doesn't make your behaviour sane, only justifiably insane ;-)\n\nComments, complaints, etc: [ joe at getahead dot org ]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoewalker%2Fserverdom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoewalker%2Fserverdom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoewalker%2Fserverdom/lists"}