var atomEntryCustomization = function()

in JSLib/src/odata-atom.js [1181:1232]


    var atomEntryCustomization = function (dom, entry, entryProperties, customization) {
        /// <summary>Applies a feed customization by transforming an Atom entry DOM element as needed.</summary>
        /// <param name="dom">DOM document used for creating any new DOM nodes required by the customization.</param>
        /// <param name="entry">DOM element for the Atom entry to which the customization is going to be applied.</param>
        /// <param name="entryProperties">DOM element containing the properties of the Atom entry.</param>
        /// <param name="customization" type="Object">Object describing an applicable feed customization.</param>
        /// <remarks>
        ///     Look into the atomfeedCustomization function for a description of the customization object.
        /// </remarks>
        /// <returns type="String">Data service version required by the applied customization</returns>

        var atomProperty = xmlFindElementByPath(entryProperties, odataXmlNs, customization.propertyPath);
        var atomPropertyNullAttribute = atomProperty && xmlAttributeNode(atomProperty, "null", odataMetaXmlNs);
        var atomPropertyValue;
        var dataServiceVersion = "1.0";

        if (atomPropertyNullAttribute && atomPropertyNullAttribute.value === "true") {
            return dataServiceVersion;
        }

        if (atomProperty) {
            atomPropertyValue = xmlInnerText(atomProperty) || "";
            if (!customization.keepInContent) {
                dataServiceVersion = "2.0";
                var parent = atomProperty.parentNode;
                var candidate = parent;

                parent.removeChild(atomProperty);
                while (candidate !== entryProperties && atomCanRemoveProperty(candidate)) {
                    parent = candidate.parentNode;
                    parent.removeChild(candidate);
                    candidate = parent;
                }
            }
        }

        var targetNode = xmlNewNodeByPath(dom, entry,
            customization.nsURI, customization.nsPrefix, customization.entryPath);

        if (targetNode.nodeType === 2) {
            targetNode.value = atomPropertyValue;
            return dataServiceVersion;
        }

        var contentKind = customization.contentKind;
        xmlAppendChildren(targetNode, [
                contentKind && xmlNewAttribute(dom, null, "type", contentKind),
                contentKind === "xhtml" ? xmlNewFragment(dom, atomPropertyValue) : atomPropertyValue
        ]);

        return dataServiceVersion;
    };