mediawiki-extensions-Visual.../modules/ve2/dm/ve.dm.js
Trevor Parscal b62beed2e2 Added implementation for ve.dm.Converter.getDataFromDom
Change-Id: I8561d4a00ba630b86fb7bcd3e347fe2c6c2f6aa3
2012-06-06 17:47:27 -07:00

29 lines
739 B
JavaScript

/**
* DataModel namespace.
*
* All classes and functions will be attached to this object to keep the global namespace clean.
*/
ve.dm = {
//'nodeFactory': Initialized in ve.dm.NodeFactory.js
//'converter': Initialized in ve.dm.Converter.js
};
ve.dm.createDomElement = function( type, attributes, doc ) {
if ( doc === undefined ) {
doc = document;
}
var element = doc.createElement( type );
for ( var key in attributes ) {
element.setAttribute( key, attributes[key] );
}
return element;
};
ve.dm.getObjectFromDomElementAttributes = function( domAttributes ) {
var attributes = {};
for ( var i = 0; i < domAttributes.length; i++ ) {
attributes[domAttributes[i].name] = domAttributes[i].value;
}
return attributes;
};