{"id":204506,"date":"2013-12-02T12:25:03","date_gmt":"2013-12-02T08:25:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=204506"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=204506","title":{"rendered":"<span class=\"post_title\">kidomi: \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 DOM-\u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u00ab\u043d\u0430 \u043b\u0435\u0442\u0443\u00bb<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u041e\u0434\u043d\u0438\u043c \u0434\u043e\u0436\u0434\u043b\u0438\u0432\u044b\u043c \u043e\u0441\u0435\u043d\u043d\u0438\u043c \u0432\u0435\u0447\u0435\u0440\u043e\u043c \u043f\u0440\u0438\u0448\u043b\u0430 \u043c\u043d\u0435 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443 \u043c\u044b\u0441\u043b\u044c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0435\u0436\u0434\u0435 \u044f \u043d\u0435 \u043f\u0438\u0441\u0430\u043b JavaScript \u043a\u043e\u0434 \u0441\u043b\u0435\u0434\u0443\u044f \u043a\u0430\u043d\u043e\u043d\u0430\u043c test-driven development (TDD). \u041b\u0438\u0445\u0430 \u0431\u0435\u0434\u0430 \u043d\u0430\u0447\u0430\u043b\u043e! \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0442\u0430\u043b\u0430 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430-\u0448\u0430\u0431\u043b\u043e\u043d\u0438\u0437\u0430\u0442\u043e\u0440 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0430\u044f \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u00abJSON \u043d\u0430 \u0432\u0445\u043e\u0434\u0435, HTMLElement \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e DOM \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435\u00bb.<\/p>\n<p>  \u0418\u0437 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c: <a href=\"http:\/\/coffeescript.org\/\">CoffeeScript<\/a>, <a href=\"http:\/\/qunitjs.com\/\">QUnit<\/a>, <a href=\"http:\/\/phantomjs.org\/\">PhantomJS<\/a>, <a href=\"https:\/\/developers.google.com\/closure\/compiler\/\">Google Closure compiler<\/a>, \u0430 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0432\u0441\u0451 \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u0434\u043e\u0431\u0440\u043e\u0433\u043e <a href=\"http:\/\/www.gnu.org\/software\/make\/\">GNU Make<\/a>. \u0421\u0442\u0430\u0442\u044c\u044f \u0434\u043b\u044f \u0432\u0441\u0435\u0445, \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0438 \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u043d\u043e \u0437\u043d\u0430\u043a\u043e\u043c \u0441 \u0432\u044b\u0448\u0435\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f\u043c\u0438 \u0438 \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0438\u0445 \u0432 \u0440\u0430\u0431\u043e\u0442\u0435.<br \/>  <a name=\"habracut\"><\/a><\/p>\n<h4>\u0427\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435?<\/h4>\n<p>  <\/p>\n<pre><code class=\"javascript\">elem = kidomi(      ['div#main.content',          ['span', {style: {color: 'blue'}}, 'Select file'],          ['form', {              name: 'inputName',              action: 'getform.php',              method: 'get'},          'Username: ',          ['input', {'type': 'text', 'name': 'user'}],          ['input', {'type': 'submit', 'value': 'Submit'}]]]) <\/code><\/pre>\n<p>  \u0413\u0434\u0435 <code>elem<\/code> \u2014 \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 <code>HTMLElement<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a:<\/p>\n<pre><code class=\"html\">&lt;div id=&quot;main&quot; class=&quot;content&quot;&gt;   &lt;span style=&quot;color: blue;&quot;&gt;Select file&lt;\/span&gt;   &lt;form name=&quot;inputName&quot; action=&quot;getform.php&quot; method=&quot;get&quot;&gt;     Username:     &lt;input type=&quot;text&quot; name=&quot;user&quot;&gt;&lt;\/input&gt;     &lt;input type=&quot;submit&quot; value=&quot;Submit&quot;&gt;&lt;\/input&gt;   &lt;\/form&gt; &lt;\/div&gt; <\/code><\/pre>\n<p>  \u0415\u0449\u0451 \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <code>&lt;a&gt;<\/code>, \u043a <code>onclick<\/code> \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043e\u0431\u0449\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443:<\/p>\n<pre><code class=\"javascript\">button = kidomi(['a.button', {href: '#'}]); button.onclick = function() { alert('Hello world!'); };  elem = kidomi(['div', ['span', 'Click this button:'], button]); <\/code><\/pre>\n<p>  \u0411\u044b\u0432\u0430\u043b\u044b\u0435 \u043b\u044e\u0434\u0438 \u0441\u0440\u0430\u0437\u0443 \u0432\u0441\u043f\u043e\u043c\u043d\u044f\u0442 <a href=\"https:\/\/github.com\/creationix\/jquery-haml\">jquery-haml<\/a>, \u043e\u0434\u043d\u0430\u043a\u043e \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f kidomi \u0447\u0435\u0440\u043f\u0430\u043b\u043e\u0441\u044c \u0438\u0437 ClojureScript-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/github.com\/Prismatic\/dommy\">dommy<\/a>.<\/p>\n<h4>\u041e \u0447\u0451\u043c \u0436\u0435 \u0441\u044b\u0440-\u0431\u043e\u0440?<\/h4>\n<p>  <\/p>\n<ul>\n<li><b>kidomi<\/b> \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043d\u0430 CoffeeScript.<\/li>\n<li>\u041e\u043d\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f Google Closure \u0432 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u043c (ADVANCED_MODE) \u0440\u0435\u0436\u0438\u043c\u0435.<\/li>\n<li>\u041e\u043d\u0430 \u043f\u043e\u043a\u0440\u044b\u0442\u0430 \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u0430\u043c\u0438.<\/li>\n<li>\u0418 \u044d\u0442\u0438 \u0442\u0435\u0441\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432 \u0442.\u0447. \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e PhantomJS.<\/li>\n<li>\u0412\u0441\u0451 \u044d\u0442\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e make.<\/li>\n<\/ul>\n<h4>\u0422\u043e\u043d\u043a\u043e\u0441\u0442\u0438 CoffeeScript<\/h4>\n<p>  \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"html\">window['kidomi'] = kidomi = (data) -&gt; ... <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c \u0441 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 CoffeeScript: \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u0435\u0441\u044c \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e-\u043e\u0431\u0451\u0440\u0442\u043a\u0443 \u0438 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0435 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e. \u041a\u0441\u0442\u0430\u0442\u0438 \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0444\u043b\u0430\u0433\u043e\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 <code>--bare<\/code>, \u043d\u043e \u0440\u0430\u0437\u0432\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u0441\u043e\u0440\u044f\u0442\u044c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0451\u043d?<\/p>\n<pre><code class=\"javascript\">(function() {   \/* ... *\/    window['kidomi'] = kidomi = function(data) {     \/* ... *\/   }    \/* ... *\/ }).call(this); <\/code><\/pre>\n<p>  \u0415\u0449\u0451 \u043e\u0434\u043d\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0438:<\/p>\n<pre><code class=\"coffeescript\">window['kidomi'] = # \u0430 \u043d\u0435 window.kidomi = <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 Google Closure, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u00ab\u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b\u00bb \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435, \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 <code>window.kidomi =<\/code><\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435, \u043a\u043e\u0434 \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u0432 \u043f\u043e\u0445\u043e\u0436\u0435\u043c \u043a\u043b\u044e\u0447\u0435:<\/p>\n<pre><code class=\"coffeescript\">kidomi.makeElementFromTagData = makeElementFromTagData = (tagData) -&gt; # ...  kidomi.addAttributes = addAttributes = (elem, data) -&gt; # ...  # \u0438 \u0442.\u0434. <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e, \u0442\u0430\u043a \u0438 \u00ab\u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f\u00bb \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e-\u043e\u0431\u044a\u0435\u043a\u0442 <code>kidomi<\/code>. \u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430: \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u0432 (\u0445\u043e\u0442\u044f \u0432 CoffeeScript \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>@name<\/code>, \u0447\u0442\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 <code>this.name<\/code>). A \u0447\u0442\u043e\u0431\u044b \u044e\u043d\u0438\u0442 \u0442\u0435\u0441\u0442\u044b \u043c\u043e\u0433\u043b\u0438 \u0434\u043e \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u0435\u0451 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u0430 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u0427\u0442\u043e \u0438 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 <code>kidomi.functionName<\/code>.<\/p>\n<h4>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h4>\n<p>  \u041f\u043e\u043c\u043d\u0438\u0442\u0435 \u0441\u0432\u043e\u0438 \u043f\u0435\u0440\u0432\u044b\u0435 \u0448\u0430\u0433\u0438 \u0432 TDD? \u041c\u043d\u0435 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u0442\u043e\u0438\u043b\u043e \u043d\u0435\u0438\u043c\u043e\u0432\u0435\u0440\u043d\u044b\u0445 \u0443\u0441\u0438\u043b\u0438\u0439 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0435\u0431\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b, \u0430 \u043f\u043e\u0441\u043b\u0435 \u2014 \u043a\u043e\u0434. \u0417\u0430\u0442\u043e, \u043a\u0430\u043a \u0431\u044b\u0441\u0442\u0440\u043e TDD \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u0442 \u0434\u0438\u0432\u0438\u0434\u0435\u043d\u0434\u044b!<\/p>\n<p>  \u041a\u0430\u043a \u0431\u044b\u043b\u043e \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u0432\u044b\u0448\u0435, \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u044e\u043d\u0438\u0442 \u0442\u0435\u0441\u0442\u043e\u0432 \u0434\u043b\u044f kidomi \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <a href=\"http:\/\/habrahabr.ru\/post\/83170\/\">QUnit<\/a>. \u041e\u0434\u0438\u043d \u0438\u0437 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"coffeescript\">test('isString', -&gt;     ok(kidomi.isString(''))     ok(not kidomi.isString({}))     ok(not kidomi.isString([]))     ok(not kidomi.isString(10)))  <\/code><\/pre>\n<p>  \u0410 \u0432\u043e\u0442 \u0438 \u0441\u0430\u043c\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f:<\/p>\n<pre><code class=\"coffeescript\">kidomi.isString = isString = (s) -&gt;     typeof(s) == 'string' or s instanceof(String); <\/code><\/pre>\n<p>  \u0421\u0442\u043e\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e kidomi.js, \u043d\u043e \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u0443\u044e <s>\u043d\u0430\u043f\u0438\u043b\u044c\u043d\u0438\u043a\u043e\u043c<\/s> \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u043c Closure kidomi.min.js. \u0412 \u0438\u0434\u0435\u0430\u043b\u0435 \u2014 \u0432\u0441\u0435 \u0442\u0435\u0441\u0442\u044b \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u0435 \u043d\u0435\u0441\u0436\u0430\u0442\u044b\u0439 \u0444\u0430\u0439\u043b \u0434\u043e\u043b\u0436\u043d\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438. \u041d\u043e \u0442\u0443\u0442 \u043c\u044b \u043d\u0430\u0442\u044b\u043a\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0432\u0441\u0435 \u0438\u043c\u0435\u043d\u0430 \u0444\u0443\u043d\u0446\u043a\u0438\u0439 \u043a\u0440\u043e\u043c\u0435 <code>kidomi<\/code> \u0431\u044b\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u044b \u0434\u043e \u043d\u0435\u0443\u0437\u043d\u0430\u0432\u0430\u0435\u043c\u043e\u0441\u0442\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 <code>isString(s)<\/code> \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432<\/p>\n<pre><code class=\"javascript\">d.e=k=function(a){return&quot;string&quot;===typeof a||a instanceof String}; <\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0441 \u044d\u0442\u0438\u043c \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c\u0441\u044f, \u043d\u0443\u0436\u043d\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0438 \u0442\u0435\u0441\u0442\u044b \u043a\u0430\u043a \u0435\u0434\u0438\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435. \u0422\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443, \u0447\u0442\u043e qunit.js \u2014 \u044d\u0442\u043e \u0432\u043d\u0435\u0448\u043d\u044f\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u0438\u0435 \u0438\u043c\u0435\u043d\u0430 \u0444\u0443\u043d\u0446\u043a\u0438\u0439, \u043a\u0430\u043a <code>test<\/code>, <code>module<\/code>, <code>ok<\/code> \u0438 \u0442.\u0434. \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0441\u0442\u0430\u0442\u044c\u0441\u044f \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/p>\n<p>  \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0438 \u0442\u0435\u0441\u0442\u044b \u0441\u043b\u0438\u043f\u043b\u0435\u043d\u044b \u0432 \u043e\u0434\u0438\u043d min.js \u0444\u0430\u0439\u043b, \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0436\u0430\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e. \u041e\u0434\u0438\u043d \u0438\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u2014 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u043b\u0438\u0448\u044c \u0434\u043b\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u043e\u043b\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 kidomi \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 3 \u043f\u0440\u043e\u0445\u043e\u0434\u0430:<\/p>\n<ol>\n<li>\u0412\u0441\u0435 \u0442\u0435\u0441\u0442\u044b \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u043d\u0435\u0441\u0436\u0430\u0442\u043e\u0439 kidomi.js. \u0422\u0435\u0441\u0442\u044b \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0432 \u043e\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430\u0445.<\/li>\n<li>\u0412\u0441\u0435 \u0442\u0435\u0441\u0442\u044b \u0441\u0436\u0438\u043c\u0430\u044e\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 kidomi.js. \u0422\u0435\u0441\u0442\u044b \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0432 \u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435.<\/li>\n<li>\u0422\u0435\u0441\u0442\u044b \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>kidomi()<\/code> \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u0441\u0436\u0430\u0442\u043e\u0439 kidomi.min.js. \u0422\u0435\u0441\u0442\u044b \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0432 \u043e\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430\u0445.<\/li>\n<\/ol>\n<h5>PhantomJS<\/h5>\n<p>  \u041a\u0430\u043a \u0443\u0436\u0435 <a href=\"http:\/\/habrahabr.ru\/post\/116789\/\">\u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u043e\u0441\u044c \u043d\u0430 \u0425\u0430\u0431\u0440\u0435<\/a>, PhantomJS \u2014 \u044d\u0442\u043e WebKit \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439\u0441\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c JS-API. \u041d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u0430\u0445 \u0438\u043d\u0442\u0435\u0440\u0435\u0442\u0430 \u0431\u044b\u043b \u043d\u0430\u0439\u0434\u0435\u043d <a href=\"https:\/\/gist.github.com\/gmarik\/1305062\">\u0441\u043a\u0440\u0438\u043f\u0442<\/a> \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 PhantomJS \u0438 QUnit \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0438 \u0432 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c: \u043e\u043d \u043f\u0430\u0440\u0441\u0438\u0442 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441 \u043a\u043e\u0434\u043e\u043c 0 (\u0443\u0441\u043f\u0435\u0445) \u0438\u043b\u0438 1 (\u043e\u0448\u0438\u0431\u043a\u0430) \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0442\u0435\u0441\u0442\u043e\u0432. \u041a\u0441\u0442\u0430\u0442\u0438, \u0432\u0441\u0435 \u0442\u0435\u0441\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435.<\/p>\n<h5>\u0421\u0431\u043e\u0440\u043a\u0430<\/h5>\n<p>  \u0414\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"http:\/\/habrahabr.ru\/post\/148167\/\">Rake<\/a>, <a href=\"http:\/\/habrahabr.ru\/post\/130419\/\">Maven<\/a>, <a href=\"http:\/\/habrahabr.ru\/post\/148274\/\">Grunt<\/a> \u0438 \u0442.\u0434., \u043d\u043e \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0432\u044b\u0448\u0435\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u043c\u0438 \u044f \u043d\u0430 \u00ab\u0432\u044b\u00bb (\u043a\u0430\u043c\u0440\u0430\u0434\u044b, \u043e\u0431\u0435\u0449\u0430\u044e \u043d\u0430\u0432\u0435\u0440\u0441\u0442\u0430\u0442\u044c \u0443\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u0435 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u043e\u0441\u0442\u0443 \u043d\u0430 \u0442\u0435\u043c\u0443 JavaScript). <i>Make<\/i> \u0436\u0435, \u043a\u0430\u043a \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0441\u044f \u0441 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u043d\u0430 \u00ab\u0423\u0440\u0430!\u00bb.<\/p>\n<p>  <i>Makefile<\/i> \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432\u0441\u0435\u0433\u043e \u0438\u0437 \u0442\u0440\u0451\u0445 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439 \u0441\u0431\u043e\u0440\u043a\u0438 (build targets): <code>${BUILD_DIR}, $(BUILD_DIR)\/kidomi.js<\/code> \u0438 <code>$(BUILD_DIR)\/kidomi.min.js<\/code> (\u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043b\u044e\u0448\u043a\u0438 \u0432 \u0432\u0438\u0434\u0435 \u0446\u0435\u043b\u0435\u0439 <code>all, clean, .PHONY<\/code> \u0438 \u0442.\u0434.). \u0412 \u043a\u043e\u043d\u0446\u0435 Makefile&#8217;\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0444\u0430\u0439\u043b <code>Makefile.testsuite.mk<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0446\u0435\u043b\u0438 \u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432\u0441\u0435\u0445 \u0440\u0430\u043d\u0435\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<h5>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h5>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u044b\u043b\u0430 \u0434\u043b\u044f \u0432\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439 \u0438 \u0432\u044b \u0443\u0437\u043d\u0430\u043b\u0438 \u0438\u0437 \u043d\u0435\u0451 \u0447\u0442\u043e-\u0442\u043e \u043d\u043e\u0432\u043e\u0435. \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 <a href=\"https:\/\/github.com\/BasicWolf\/kidomi\">kidomi<\/a> \u043e\u0442\u043a\u0440\u044b\u0442 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0445. <a href=\"https:\/\/github.com\/BasicWolf\/kidomi\/releases\">\u0410\u0440\u0445\u0438\u0432\u044b<\/a> \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0412\u0441\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438, \u0441\u043e\u0432\u0435\u0442\u044b, \u043e\u0442\u0437\u044b\u0432\u044b \u0438 \u043a\u0440\u0438\u0442\u0438\u043a\u0430 \u0433\u043e\u0440\u044f\u0447\u043e \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442\u0441\u044f! <br \/>  \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!    \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/204506\/\"> http:\/\/habrahabr.ru\/post\/204506\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u041e\u0434\u043d\u0438\u043c \u0434\u043e\u0436\u0434\u043b\u0438\u0432\u044b\u043c \u043e\u0441\u0435\u043d\u043d\u0438\u043c \u0432\u0435\u0447\u0435\u0440\u043e\u043c \u043f\u0440\u0438\u0448\u043b\u0430 \u043c\u043d\u0435 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443 \u043c\u044b\u0441\u043b\u044c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0435\u0436\u0434\u0435 \u044f \u043d\u0435 \u043f\u0438\u0441\u0430\u043b JavaScript \u043a\u043e\u0434 \u0441\u043b\u0435\u0434\u0443\u044f \u043a\u0430\u043d\u043e\u043d\u0430\u043c test-driven development (TDD). \u041b\u0438\u0445\u0430 \u0431\u0435\u0434\u0430 \u043d\u0430\u0447\u0430\u043b\u043e! \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0442\u0430\u043b\u0430 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430-\u0448\u0430\u0431\u043b\u043e\u043d\u0438\u0437\u0430\u0442\u043e\u0440 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0430\u044f \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u00abJSON \u043d\u0430 \u0432\u0445\u043e\u0434\u0435, HTMLElement \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e DOM \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435\u00bb.<\/p>\n<p>  \u0418\u0437 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c: <a href=\"http:\/\/coffeescript.org\/\">CoffeeScript<\/a>, <a href=\"http:\/\/qunitjs.com\/\">QUnit<\/a>, <a href=\"http:\/\/phantomjs.org\/\">PhantomJS<\/a>, <a href=\"https:\/\/developers.google.com\/closure\/compiler\/\">Google Closure compiler<\/a>, \u0430 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0432\u0441\u0451 \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u0434\u043e\u0431\u0440\u043e\u0433\u043e <a href=\"http:\/\/www.gnu.org\/software\/make\/\">GNU Make<\/a>. \u0421\u0442\u0430\u0442\u044c\u044f \u0434\u043b\u044f \u0432\u0441\u0435\u0445, \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0438 \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u043d\u043e \u0437\u043d\u0430\u043a\u043e\u043c \u0441 \u0432\u044b\u0448\u0435\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f\u043c\u0438 \u0438 \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0438\u0445 \u0432 \u0440\u0430\u0431\u043e\u0442\u0435.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-204506","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/204506","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=204506"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/204506\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=204506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=204506"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=204506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}