Comparing version 3.1.4 to 3.1.5
@@ -320,10 +320,16 @@ (function (document) { | ||
for (var i = 0; i < this.nodes.length; i++) { | ||
if (this.nodes[i].id == id) { | ||
return this.nodes[i]; | ||
} | ||
var node = this.nodes[i]; | ||
var element = this.nodes[i].getElementById(id); | ||
if (element) { | ||
return element; | ||
} | ||
do { | ||
if (node.id == id) { | ||
return node; | ||
} | ||
// Iterate over children. | ||
node = node.firstChild || node.nextSibling || function () { | ||
while ((node = node.parentNode) && !node.nextSibling); | ||
return node ? node.nextSibling : null; | ||
}(); | ||
} while (node); | ||
} | ||
@@ -339,3 +345,2 @@ return null; | ||
for (var i = 0; i < this.nodes.length; i++) { | ||
// TODO: Use polyfill for work in Opera 12.16. | ||
if (this.nodes[i].matches && this.nodes[i].matches(query)) { | ||
@@ -342,0 +347,0 @@ return this.nodes[i]; |
{ | ||
"name": "monkberry", | ||
"version": "3.1.4", | ||
"version": "3.1.5", | ||
"description": "JavaScript DOM Template Engine", | ||
@@ -5,0 +5,0 @@ "bin": "bin/monkberry", |
@@ -88,3 +88,3 @@ # Monkberry - JavaScript template engine | ||
var view = monkberry.render('template'); | ||
document.body.appendChild(view.dom()); | ||
view.appendTo(document.body); | ||
@@ -135,3 +135,3 @@ view.update({ | ||
```js | ||
document.getElementById('root').appendChild(view.dom()); | ||
document.getElementById('root').appendChild(view.createDocument()); | ||
``` | ||
@@ -367,3 +367,3 @@ | ||
monkberry.wrappers.logo = function (view) { | ||
view.dom().querySelector('.svg-icon').appendChild(svgIconNodes); | ||
view.querySelector('.svg-icon').appendChild(svgIconNodes); | ||
return view; | ||
@@ -378,3 +378,3 @@ }; | ||
Transformers allow to modify [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree) before compilation of templates. | ||
List of AST nodes can be founded here: [ast.js](https://github.com/monkberry/monkberry/blob/master/parsers/ast.js) | ||
List of AST nodes can be founded here: [ast.js](https://github.com/monkberry/parser/blob/master/src/ast.js) | ||
Example of transform which trim whitespaces: [whitespace.js](https://github.com/monkberry/monkberry/blob/master/src/optimize/whitespace.js) | ||
@@ -393,3 +393,3 @@ | ||
Now Monkberry support only one type of parser, mustage like (`monk` named). But it can be extender with custom parsers. Every parser must return valid [AST](https://github.com/monkberry/monkberry/blob/master/parsers/ast.js) tree. | ||
Now Monkberry support only one type of parser, mustage like (`monk` named). But it can be extender with custom parsers. Every parser must return valid [AST](https://github.com/monkberry/parser/blob/master/src/ast.js) tree. | ||
@@ -504,3 +504,3 @@ ```js | ||
> Note what this function uses [Element.matches()](https://developer.mozilla.org/en-US/docs/Web/API/Element/matches) for checking root nodes. | ||
> Note what this function uses [Element.matches()](https://developer.mozilla.org/en-US/docs/Web/API/Element/matches) for checking root nodes. Include polyfill for matches if you use it. | ||
@@ -507,0 +507,0 @@ |
82402
1768