MCPcopy Index your code
hub / github.com/microsoft/SandDance / getValueForProperty

Function getValueForProperty

docs/external/js/react-dom.development.js:1199–1262  ·  view source on GitHub ↗

* Get the value for a property on a node. Only used in DEV for SSR validation. * The "expected" argument is used as a hint of what the expected value is. * Some properties have multiple equivalent values.

(node, name, expected, propertyInfo)

Source from the content-addressed store, hash-verified

1197 * Some properties have multiple equivalent values.
1198 */
1199 function getValueForProperty(node, name, expected, propertyInfo) {
1200 {
1201 if (propertyInfo.mustUseProperty) {
1202 var propertyName = propertyInfo.propertyName;
1203 return node[propertyName];
1204 } else {
1205 if ( propertyInfo.sanitizeURL) {
1206 // If we haven't fully disabled javascript: URLs, and if
1207 // the hydration is successful of a javascript: URL, we
1208 // still want to warn on the client.
1209 sanitizeURL('' + expected);
1210 }
1211
1212 var attributeName = propertyInfo.attributeName;
1213 var stringValue = null;
1214
1215 if (propertyInfo.type === OVERLOADED_BOOLEAN) {
1216 if (node.hasAttribute(attributeName)) {
1217 var value = node.getAttribute(attributeName);
1218
1219 if (value === '') {
1220 return true;
1221 }
1222
1223 if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
1224 return value;
1225 }
1226
1227 if (value === '' + expected) {
1228 return expected;
1229 }
1230
1231 return value;
1232 }
1233 } else if (node.hasAttribute(attributeName)) {
1234 if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
1235 // We had an attribute but shouldn't have had one, so read it
1236 // for the error message.
1237 return node.getAttribute(attributeName);
1238 }
1239
1240 if (propertyInfo.type === BOOLEAN) {
1241 // If this was a boolean, it doesn't matter what the value is
1242 // the fact that we have it is the same as the expected.
1243 return expected;
1244 } // Even if this property uses a namespace we use getAttribute
1245 // because we assume its namespaced name is the same as our config.
1246 // To use getAttributeNS we need the local name which we don't have
1247 // in our config atm.
1248
1249
1250 stringValue = node.getAttribute(attributeName);
1251 }
1252
1253 if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
1254 return stringValue === null ? expected : stringValue;
1255 } else if (stringValue === '' + expected) {
1256 return expected;

Callers 1

diffHydratedPropertiesFunction · 0.85

Calls 2

shouldRemoveAttributeFunction · 0.85
sanitizeURLFunction · 0.70

Tested by

no test coverage detected