/
mock.js
31 lines (26 loc) · 1018 Bytes
/
mock.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
import { register, each } from "../util/index";
import { $NullElement } from "../types";
register({
/**
* Return {@link $Element} initialized with all existing live extensions.
* Also exposes private functions that do not usually exist. Accepts the
* same arguments as {@link DOM.create}
* @memberof $Document#
* @alias $Document#mock
* @param {String} value EmmetString or HTMLString
* @param {Object|Array} [varMap] key/value map of variables
* @return {$Element} a mocked instance
* @see $Document#create
*/
mock(content, varMap) {
if (!content) return new $NullElement();
var result = this.create(content, varMap),
mappings = this._["<%= prop('mappings') %>"],
applyExtensions = (node) => {
mappings.forEach((ext) => { ext(node, true) });
each.call(node.children, applyExtensions);
};
applyExtensions(result[0]);
return result;
}
});