-
-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathmakeInlineElement.js
More file actions
13 lines (13 loc) · 896 Bytes
/
makeInlineElement.js
File metadata and controls
13 lines (13 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
/**
* Helper to construct an object representing an XLIFF inline element (an XML element within a `source` or `target` value).
* @param type The inline element type. This should be one of the constants defined in ElementTypes.js
* @param attributes (optional) An object with property/value pairs that correspond to the attributes to add to the element.
* @param contents (optional) A string or Array containing the contents to be inserted between the opening and closing tags
* (if the element is a type that supports contents).
* @return An object in the proper structure to represent the XLIFF inline element as supported by this library
*/
export default function makeInlineElement (type, attributes, contents) {
const contentsObj = contents !== undefined ? { contents } : {}
const dataObj = Object.assign({}, attributes, contentsObj)
return { [type]: dataObj }
}