2012-05-10 04:11:09 +00:00
|
|
|
/* Static Members */
|
|
|
|
|
|
|
|
ve.example = {};
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
ve.example.getSelectNodesCases = function( doc ) {
|
|
|
|
var lookup = ve.example.lookupNode,
|
|
|
|
documentNode = doc.getDocumentNode();
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
'actual': doc.selectNodes( new ve.Range( 0, 3 ), 'leaves' ),
|
|
|
|
'expected': [
|
2012-05-15 05:54:53 +00:00
|
|
|
// heading/text
|
2012-05-10 22:03:23 +00:00
|
|
|
{
|
|
|
|
'node': lookup( documentNode, 0, 0 ),
|
|
|
|
'range': new ve.Range( 1, 3 ),
|
|
|
|
'index': 0,
|
2012-06-04 23:18:29 +00:00
|
|
|
'nodeRange': new ve.Range( 1, 4 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 1, 4 )
|
2012-05-10 22:03:23 +00:00
|
|
|
}
|
2012-05-15 05:54:53 +00:00
|
|
|
],
|
2012-05-15 07:25:27 +00:00
|
|
|
'msg': 'partial leaf results have ranges with global offsets'
|
2012-05-10 04:11:09 +00:00
|
|
|
},
|
|
|
|
{
|
2012-06-08 05:08:49 +00:00
|
|
|
'actual': doc.selectNodes( new ve.Range( 0, 11 ), 'leaves' ),
|
2012-05-10 04:11:09 +00:00
|
|
|
'expected': [
|
2012-05-15 05:54:53 +00:00
|
|
|
// heading/text
|
2012-05-10 22:03:23 +00:00
|
|
|
{
|
|
|
|
'node': lookup( documentNode, 0, 0 ),
|
|
|
|
'index': 0,
|
2012-06-04 23:18:29 +00:00
|
|
|
'nodeRange': new ve.Range( 1, 4 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 1, 4 )
|
2012-05-10 22:03:23 +00:00
|
|
|
},
|
2012-06-08 05:08:49 +00:00
|
|
|
// table/tableSection/tableRow/tableCell/paragraph/text
|
2012-05-10 22:03:23 +00:00
|
|
|
{
|
2012-06-08 05:08:49 +00:00
|
|
|
'node': lookup( documentNode, 1, 0, 0, 0, 0, 0 ),
|
2012-05-10 22:03:23 +00:00
|
|
|
'index': 0,
|
2012-06-08 05:08:49 +00:00
|
|
|
'nodeRange': new ve.Range( 10, 11 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 10, 11 )
|
2012-05-10 22:03:23 +00:00
|
|
|
}
|
2012-05-15 05:54:53 +00:00
|
|
|
],
|
|
|
|
'msg': 'leaf nodes do not have ranges, leaf nodes from different levels'
|
2012-05-10 04:11:09 +00:00
|
|
|
},
|
|
|
|
{
|
2012-06-08 05:08:49 +00:00
|
|
|
'actual': doc.selectNodes( new ve.Range( 29, 43 ), 'leaves' ),
|
2012-05-10 04:11:09 +00:00
|
|
|
'expected': [
|
2012-06-08 05:08:49 +00:00
|
|
|
// table/tableSection/tableRow/tableCell/list/listItem/paragraph/text
|
2012-05-10 22:03:23 +00:00
|
|
|
{
|
2012-06-08 05:08:49 +00:00
|
|
|
'node': lookup( documentNode, 1, 0, 0, 0, 2, 0, 0, 0 ),
|
2012-05-10 22:03:23 +00:00
|
|
|
'index': 0,
|
2012-06-08 05:08:49 +00:00
|
|
|
'nodeRange': new ve.Range( 29, 30 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 29, 30 )
|
2012-05-10 22:03:23 +00:00
|
|
|
},
|
2012-05-10 04:11:09 +00:00
|
|
|
// preformatted/text
|
2012-05-10 22:03:23 +00:00
|
|
|
{
|
|
|
|
'node': lookup( documentNode, 2, 0 ),
|
|
|
|
'index': 0,
|
2012-06-08 05:08:49 +00:00
|
|
|
'nodeRange': new ve.Range( 38, 39 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 38, 39 )
|
2012-05-10 22:03:23 +00:00
|
|
|
},
|
2012-05-15 05:54:53 +00:00
|
|
|
// preformatted/image
|
2012-05-10 22:03:23 +00:00
|
|
|
{
|
|
|
|
'node': lookup( documentNode, 2, 1 ),
|
|
|
|
'index': 1,
|
2012-06-08 05:08:49 +00:00
|
|
|
'nodeRange': new ve.Range( 40, 40 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 39, 41 )
|
2012-05-10 22:03:23 +00:00
|
|
|
},
|
2012-05-10 04:11:09 +00:00
|
|
|
// preformatted/text
|
2012-05-10 22:03:23 +00:00
|
|
|
{
|
|
|
|
'node': lookup( documentNode, 2, 2 ),
|
|
|
|
'index': 2,
|
2012-06-08 05:08:49 +00:00
|
|
|
'nodeRange': new ve.Range( 41, 42 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 41, 42 )
|
2012-05-10 22:03:23 +00:00
|
|
|
}
|
2012-05-15 05:54:53 +00:00
|
|
|
],
|
|
|
|
'msg': 'leaf nodes that are not text nodes'
|
2012-05-10 04:11:09 +00:00
|
|
|
},
|
|
|
|
{
|
2012-06-08 05:08:49 +00:00
|
|
|
'actual': doc.selectNodes( new ve.Range( 2, 16 ), 'siblings' ),
|
2012-05-10 04:11:09 +00:00
|
|
|
'expected': [
|
|
|
|
// heading
|
2012-05-10 22:03:23 +00:00
|
|
|
{
|
|
|
|
'node': lookup( documentNode, 0 ),
|
|
|
|
'range': new ve.Range( 2, 4 ),
|
|
|
|
'index': 0,
|
2012-06-04 23:18:29 +00:00
|
|
|
'nodeRange': new ve.Range( 1, 4 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 0, 5 )
|
2012-05-10 22:03:23 +00:00
|
|
|
},
|
2012-05-10 04:11:09 +00:00
|
|
|
// table
|
2012-05-10 22:03:23 +00:00
|
|
|
{
|
|
|
|
'node': lookup( documentNode, 1 ),
|
2012-06-08 05:08:49 +00:00
|
|
|
'range': new ve.Range( 6, 16 ),
|
2012-05-10 22:03:23 +00:00
|
|
|
'index': 1,
|
2012-06-08 05:08:49 +00:00
|
|
|
'nodeRange': new ve.Range( 6, 36 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 5, 37 )
|
2012-05-10 22:03:23 +00:00
|
|
|
}
|
2012-05-15 05:54:53 +00:00
|
|
|
],
|
|
|
|
'msg': 'siblings at the document level'
|
2012-05-10 04:11:09 +00:00
|
|
|
},
|
|
|
|
{
|
2012-06-08 05:08:49 +00:00
|
|
|
'actual': doc.selectNodes( new ve.Range( 2, 51 ), 'siblings' ),
|
2012-05-10 04:11:09 +00:00
|
|
|
'expected': [
|
|
|
|
// heading
|
2012-05-10 22:03:23 +00:00
|
|
|
{
|
|
|
|
'node': lookup( documentNode, 0 ),
|
|
|
|
'range': new ve.Range( 2, 4 ),
|
|
|
|
'index': 0,
|
2012-06-04 23:18:29 +00:00
|
|
|
'nodeRange': new ve.Range( 1, 4 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 0, 5 )
|
2012-05-10 22:03:23 +00:00
|
|
|
},
|
2012-05-10 04:11:09 +00:00
|
|
|
// table
|
2012-05-10 22:03:23 +00:00
|
|
|
{
|
|
|
|
'node': lookup( documentNode, 1 ),
|
|
|
|
'index': 1,
|
2012-06-08 05:08:49 +00:00
|
|
|
'nodeRange': new ve.Range( 6, 36 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 5, 37 )
|
2012-05-10 22:03:23 +00:00
|
|
|
},
|
2012-05-10 04:11:09 +00:00
|
|
|
// preformatted
|
2012-05-10 22:03:23 +00:00
|
|
|
{
|
|
|
|
'node': lookup( documentNode, 2 ),
|
|
|
|
'index': 2,
|
2012-06-08 05:08:49 +00:00
|
|
|
'nodeRange': new ve.Range( 38, 42 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 37, 43 )
|
2012-05-10 22:03:23 +00:00
|
|
|
},
|
2012-05-10 04:11:09 +00:00
|
|
|
// definitionList
|
2012-05-10 22:03:23 +00:00
|
|
|
{
|
|
|
|
'node': lookup( documentNode, 3 ),
|
2012-06-08 05:08:49 +00:00
|
|
|
'range': new ve.Range( 44, 51 ),
|
2012-05-10 22:03:23 +00:00
|
|
|
'index': 3,
|
2012-06-08 05:08:49 +00:00
|
|
|
'nodeRange': new ve.Range( 44, 54 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 43, 55 )
|
2012-05-10 22:03:23 +00:00
|
|
|
}
|
2012-05-15 05:54:53 +00:00
|
|
|
],
|
|
|
|
'msg': 'more than 2 siblings at the document level'
|
2012-05-10 23:08:15 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'actual': doc.selectNodes( new ve.Range( 1, 1 ), 'leaves' ),
|
|
|
|
'expected': [
|
|
|
|
// heading/text
|
|
|
|
{
|
|
|
|
'node': lookup( documentNode, 0, 0 ),
|
|
|
|
'range': new ve.Range( 1, 1 ),
|
|
|
|
'index': 0,
|
2012-06-04 23:18:29 +00:00
|
|
|
'nodeRange': new ve.Range( 1, 4 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 1, 4 )
|
2012-05-10 23:08:15 +00:00
|
|
|
}
|
2012-05-15 05:54:53 +00:00
|
|
|
],
|
|
|
|
'msg': 'zero-length range at the start of a text node returns text node rather than parent'
|
2012-05-10 23:42:16 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'actual': doc.selectNodes( new ve.Range( 4, 4 ), 'leaves' ),
|
|
|
|
'expected': [
|
|
|
|
// heading/text
|
|
|
|
{
|
|
|
|
'node': lookup( documentNode, 0, 0 ),
|
|
|
|
'range': new ve.Range( 4, 4 ),
|
|
|
|
'index': 0,
|
2012-06-04 23:18:29 +00:00
|
|
|
'nodeRange': new ve.Range( 1, 4 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 1, 4 )
|
2012-05-10 23:42:16 +00:00
|
|
|
}
|
2012-05-15 05:54:53 +00:00
|
|
|
],
|
|
|
|
'msg': 'zero-length range at the end of a text node returns text node rather than parent'
|
2012-05-10 23:42:16 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'actual': doc.selectNodes( new ve.Range( 2, 3 ), 'leaves' ),
|
|
|
|
'expected': [
|
|
|
|
// heading/text
|
|
|
|
{
|
|
|
|
'node': lookup( documentNode, 0, 0 ),
|
|
|
|
'range': new ve.Range( 2, 3 ),
|
|
|
|
'index': 0,
|
2012-06-04 23:18:29 +00:00
|
|
|
'nodeRange': new ve.Range( 1, 4 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 1, 4 )
|
2012-05-10 23:42:16 +00:00
|
|
|
}
|
2012-05-15 05:54:53 +00:00
|
|
|
],
|
|
|
|
'msg': 'range entirely within one leaf node'
|
2012-05-11 03:08:12 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'actual': doc.selectNodes( new ve.Range( 5, 5 ), 'leaves' ),
|
|
|
|
'expected': [
|
|
|
|
// document
|
|
|
|
{
|
|
|
|
'node': documentNode,
|
|
|
|
'range': new ve.Range( 5, 5 ),
|
|
|
|
// no 'index' because documentNode has no parent
|
|
|
|
'indexInNode': 1,
|
2012-06-08 05:08:49 +00:00
|
|
|
'nodeRange': new ve.Range( 0, 61 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 0, 61 )
|
2012-05-11 03:08:12 +00:00
|
|
|
}
|
2012-05-15 05:54:53 +00:00
|
|
|
],
|
|
|
|
'msg': 'zero-length range between two children of the document'
|
2012-05-15 01:44:19 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'actual': doc.selectNodes( new ve.Range( 0, 0 ), 'leaves' ),
|
|
|
|
'expected': [
|
|
|
|
// document
|
|
|
|
{
|
|
|
|
'node': documentNode,
|
|
|
|
'range': new ve.Range( 0, 0 ),
|
|
|
|
// no 'index' because documentNode has no parent
|
|
|
|
'indexInNode': 0,
|
2012-06-08 05:08:49 +00:00
|
|
|
'nodeRange': new ve.Range( 0, 61 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 0, 61 )
|
2012-05-15 01:44:19 +00:00
|
|
|
}
|
2012-05-15 05:54:53 +00:00
|
|
|
],
|
|
|
|
'msg': 'zero-length range at the start of the document'
|
2012-06-05 13:49:30 +00:00
|
|
|
},
|
|
|
|
{
|
2012-06-08 05:08:49 +00:00
|
|
|
'actual': doc.selectNodes( new ve.Range( 32, 39 ), 'leaves' ),
|
2012-06-05 13:49:30 +00:00
|
|
|
'expected': [
|
|
|
|
// preformatted/text
|
|
|
|
{
|
|
|
|
'node': lookup( documentNode, 2, 0 ),
|
|
|
|
// no 'range' because the text node is covered completely
|
|
|
|
'index': 0,
|
2012-06-08 05:08:49 +00:00
|
|
|
'nodeRange': new ve.Range( 38, 39 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 38, 39 )
|
2012-06-05 13:49:30 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
'msg': 'range with 5 closings and a text node'
|
2012-06-06 18:30:16 +00:00
|
|
|
},
|
|
|
|
{
|
2012-06-08 05:08:49 +00:00
|
|
|
'actual': doc.selectNodes( new ve.Range( 2, 57 ), 'covered' ),
|
2012-06-06 18:30:16 +00:00
|
|
|
'expected': [
|
|
|
|
// heading/text
|
|
|
|
{
|
|
|
|
'node': lookup( documentNode, 0, 0 ),
|
|
|
|
'range': new ve.Range( 2, 4 ),
|
|
|
|
'index': 0,
|
|
|
|
'nodeRange': new ve.Range( 1, 4 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 1, 4 )
|
|
|
|
},
|
|
|
|
// table
|
|
|
|
{
|
|
|
|
'node': lookup( documentNode, 1 ),
|
|
|
|
// no 'range' because the table is covered completely
|
|
|
|
'index': 1,
|
2012-06-08 05:08:49 +00:00
|
|
|
'nodeRange': new ve.Range( 6, 36 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 5, 37 )
|
2012-06-06 18:30:16 +00:00
|
|
|
},
|
|
|
|
// preformatted
|
|
|
|
{
|
|
|
|
'node': lookup( documentNode, 2 ),
|
|
|
|
// no 'range' because the node is covered completely
|
|
|
|
'index': 2,
|
2012-06-08 05:08:49 +00:00
|
|
|
'nodeRange': new ve.Range( 38, 42 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 37, 43 )
|
2012-06-06 18:30:16 +00:00
|
|
|
},
|
|
|
|
// definitionList
|
|
|
|
{
|
|
|
|
'node': lookup( documentNode, 3 ),
|
|
|
|
// no 'range' because the node is covered completely
|
|
|
|
'index': 3,
|
2012-06-08 05:08:49 +00:00
|
|
|
'nodeRange': new ve.Range( 44, 54 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 43, 55 )
|
2012-06-06 18:30:16 +00:00
|
|
|
},
|
|
|
|
// paragraph/text
|
|
|
|
{
|
|
|
|
'node': lookup( documentNode, 4, 0 ),
|
|
|
|
// no 'range' because the text node is covered completely
|
|
|
|
'index': 0,
|
2012-06-08 05:08:49 +00:00
|
|
|
'nodeRange': new ve.Range( 56, 57 ),
|
|
|
|
'nodeOuterRange': new ve.Range( 56, 57 )
|
2012-06-06 18:30:16 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
'msg': 'range from the first heading into the second-to-last paragraph, in covered mode'
|
2012-05-10 04:11:09 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2012-05-15 07:25:27 +00:00
|
|
|
* Builds a summary of a node tree.
|
2012-05-14 22:05:09 +00:00
|
|
|
*
|
2012-05-15 07:25:27 +00:00
|
|
|
* Generated summaries contain node types, lengths, outer lengths, attributes and summaries for
|
|
|
|
* each child recusively. It's simple and fast to use deepEqual on this.
|
2012-05-14 22:05:09 +00:00
|
|
|
*
|
2012-05-10 04:11:09 +00:00
|
|
|
* @method
|
2012-05-15 07:25:27 +00:00
|
|
|
* @param {ve.Node} node Node tree to summarize
|
|
|
|
* @param {Boolean} [shallow] Do not summarize each child recursively
|
|
|
|
* @returns {Object} Summary of node tree
|
2012-05-10 04:11:09 +00:00
|
|
|
*/
|
2012-05-15 07:25:27 +00:00
|
|
|
ve.example.getNodeTreeSummary = function( node, shallow ) {
|
|
|
|
var summary = {
|
|
|
|
'getType': node.getType(),
|
|
|
|
'getLength': node.getLength(),
|
|
|
|
'getOuterLength': node.getOuterLength(),
|
|
|
|
'attributes': node.attributes
|
|
|
|
};
|
|
|
|
if ( node.children !== undefined ) {
|
|
|
|
summary['children.length'] = node.children.length;
|
|
|
|
if ( !shallow ) {
|
|
|
|
summary.children = [];
|
|
|
|
for ( var i = 0; i < node.children.length; i++ ) {
|
|
|
|
summary.children.push( ve.example.getNodeTreeSummary( node.children[i] ) );
|
|
|
|
}
|
2012-05-10 04:11:09 +00:00
|
|
|
}
|
|
|
|
}
|
2012-05-15 07:25:27 +00:00
|
|
|
return summary;
|
2012-05-10 04:11:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2012-05-15 07:25:27 +00:00
|
|
|
* Builds a summary of a node selection.
|
2012-05-14 22:05:09 +00:00
|
|
|
*
|
2012-05-15 07:25:27 +00:00
|
|
|
* Generated summaries contain length of results as well as node summaries, ranges, indexes, indexes
|
|
|
|
* within parent and node ranges for each result. It's simple and fast to use deepEqual on this.
|
2012-05-14 22:05:09 +00:00
|
|
|
*
|
2012-05-10 04:11:09 +00:00
|
|
|
* @method
|
2012-05-15 07:25:27 +00:00
|
|
|
* @param {Object[]} selection Selection to summarize
|
|
|
|
* @returns {Object} Summary of selection
|
2012-05-10 04:11:09 +00:00
|
|
|
*/
|
2012-05-15 07:25:27 +00:00
|
|
|
ve.example.getNodeSelectionSummary = function( selection ) {
|
|
|
|
var summary = {
|
|
|
|
'length': selection.length
|
|
|
|
};
|
|
|
|
if ( selection.length ) {
|
|
|
|
summary.results = [];
|
|
|
|
for ( var i = 0; i < selection.length; i++ ) {
|
|
|
|
summary.results.push( {
|
|
|
|
'node': ve.example.getNodeTreeSummary( selection[i].node, true ),
|
|
|
|
'range': selection[i].range,
|
|
|
|
'index': selection[i].index,
|
|
|
|
'indexInNode': selection[i].indexInNode,
|
2012-06-04 23:18:29 +00:00
|
|
|
'nodeRange': selection[i].nodeRange,
|
2012-06-06 18:46:51 +00:00
|
|
|
'nodeOuterRange': selection[i].nodeOuterRange
|
2012-05-15 07:25:27 +00:00
|
|
|
} );
|
2012-05-10 04:11:09 +00:00
|
|
|
}
|
|
|
|
}
|
2012-05-15 07:25:27 +00:00
|
|
|
return summary;
|
2012-05-10 04:11:09 +00:00
|
|
|
};
|
|
|
|
|
2012-06-06 17:17:30 +00:00
|
|
|
/**
|
|
|
|
* Builds a summary of an HTML element.
|
|
|
|
*
|
2012-06-08 22:15:22 +00:00
|
|
|
* Summaries include node name, text, attributes and recursive summaries of children.
|
2012-06-06 17:17:30 +00:00
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @param {HTMLElement} element Element to summarize
|
|
|
|
* @returns {Object} Summary of element
|
|
|
|
*/
|
2012-06-07 00:47:27 +00:00
|
|
|
ve.example.getDomElementSummary = function( element ) {
|
2012-06-08 22:15:22 +00:00
|
|
|
var $element = $( element ),
|
|
|
|
summary = {
|
|
|
|
'type': element.nodeName.toLowerCase(),
|
|
|
|
'text': $element.text(),
|
|
|
|
'attributes': {},
|
|
|
|
'children': []
|
|
|
|
},
|
|
|
|
i;
|
|
|
|
// Gather attributes
|
|
|
|
for ( i = 0; i < element.attributes.length; i++ ) {
|
|
|
|
summary.attributes[element.attributes[i].name] = element.attributes[i].value;
|
|
|
|
}
|
|
|
|
// Summarize children
|
|
|
|
for ( i = 0; i < element.children.length; i++ ) {
|
|
|
|
summary.children.push( ve.example.getDomElementSummary( element.children[i] ) );
|
|
|
|
}
|
|
|
|
return summary;
|
2012-06-06 17:17:30 +00:00
|
|
|
};
|
|
|
|
|
2012-05-10 04:11:09 +00:00
|
|
|
/**
|
|
|
|
* Looks up a value in a node tree.
|
2012-05-14 22:05:09 +00:00
|
|
|
*
|
2012-05-10 04:11:09 +00:00
|
|
|
* @method
|
|
|
|
* @param {ve.Node} root Root node to lookup from
|
|
|
|
* @param {Integer} [...] Index path
|
|
|
|
* @param {ve.Node} Node at given path
|
|
|
|
*/
|
|
|
|
ve.example.lookupNode = function( root ) {
|
|
|
|
var node = root;
|
|
|
|
for ( var i = 1; i < arguments.length; i++ ) {
|
|
|
|
node = node.children[arguments[i]];
|
|
|
|
}
|
|
|
|
return node;
|
|
|
|
};
|
2012-06-07 22:02:25 +00:00
|
|
|
|
|
|
|
ve.example.createDomElement = function( type, attributes ) {
|
|
|
|
var element = document.createElement( type );
|
|
|
|
for ( var key in attributes ) {
|
|
|
|
element.setAttribute( key, attributes[key] );
|
|
|
|
}
|
|
|
|
return element;
|
|
|
|
};
|