MCPcopy Create free account
hub / github.com/microsoft/SandDance / getNativeProps

Function getNativeProps

docs/app/js/sanddance-app.js:25128–25147  ·  view source on GitHub ↗
(// eslint-disable-next-line @typescript-eslint/no-explicit-any
props, allowedPropNames, excludedPropNames)

Source from the content-addressed store, hash-verified

25126var imageProperties = imgProperties;
25127var divProperties = htmlElementProperties;
25128function getNativeProps(// eslint-disable-next-line @typescript-eslint/no-explicit-any
25129props, allowedPropNames, excludedPropNames) {
25130 // It'd be great to properly type this while allowing 'aria-` and 'data-' attributes like TypeScript does for
25131 // JSX attributes, but that ability is hardcoded into the TS compiler with no analog in TypeScript typings.
25132 // Then we'd be able to enforce props extends native props (including aria- and data- attributes), and then
25133 // return native props.
25134 // We should be able to do this once this PR is merged: https://github.com/microsoft/TypeScript/pull/26797
25135 var _a;
25136 var isArray = Array.isArray(allowedPropNames);
25137 // eslint-disable-next-line @typescript-eslint/no-explicit-any
25138 var result = {};
25139 var keys = Object.keys(props);
25140 for(var _i = 0, keys_2 = keys; _i < keys_2.length; _i++){
25141 var key = keys_2[_i];
25142 var isNativeProp = !isArray && allowedPropNames[key] || isArray && allowedPropNames.indexOf(key) >= 0 || key.indexOf("data-") === 0 || key.indexOf("aria-") === 0;
25143 if (isNativeProp && (!excludedPropNames || ((_a = excludedPropNames) === null || _a === void 0 ? void 0 : _a.indexOf(key)) === -1)) // eslint-disable-next-line @typescript-eslint/no-explicit-any
25144 result[key] = props[key];
25145 }
25146 return result;
25147}
25148
25149},{"@parcel/transformer-js/src/esmodule-helpers.js":"jA2du"}],"laxhl":[function(require,module,exports) {
25150var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected