Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gnoff committed Feb 7, 2023
1 parent 0b46ee6 commit 607f54d
Show file tree
Hide file tree
Showing 28 changed files with 502 additions and 348 deletions.
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
jsxBracketSameLine: true,
trailingComma: 'es5',
printWidth: 80,
parser: 'babel',
parser: 'flow',
arrowParens: 'avoid',
overrides: [
{
Expand Down
27 changes: 6 additions & 21 deletions packages/react-dom-bindings/src/client/ReactDOMFloatClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ import ReactDOMSharedInternals from 'shared/ReactDOMSharedInternals.js';
const {Dispatcher} = ReactDOMSharedInternals;
import {DOCUMENT_NODE} from '../shared/HTMLNodeType';
import {
warnOnMissingHrefAndRel,
validatePreloadResourceDifference,
validateURLKeyedUpdatedProps,
validateStyleResourceDifference,
validateScriptResourceDifference,
validateLinkPropsForStyleResource,
validateLinkPropsForPreloadResource,
validatePreloadArguments,
validatePreinitArguments,
} from '../shared/ReactDOMResourceValidation';
Expand Down Expand Up @@ -178,9 +171,8 @@ function preload(href: string, options: PreloadOptions) {
ownerDocument
) {
const as = options.as;
const limitedEscapedHref = escapeSelectorAttributeValueInsideDoubleQuotes(
href,
);
const limitedEscapedHref =
escapeSelectorAttributeValueInsideDoubleQuotes(href);
const preloadKey = `link[rel="preload"][as="${as}"][href="${limitedEscapedHref}"]`;
let key = preloadKey;
switch (as) {
Expand Down Expand Up @@ -256,9 +248,8 @@ function preinit(href: string, options: PreinitOptions) {
// matching preload with this href
const preloadDocument = getDocumentForPreloads();
if (preloadDocument) {
const limitedEscapedHref = escapeSelectorAttributeValueInsideDoubleQuotes(
href,
);
const limitedEscapedHref =
escapeSelectorAttributeValueInsideDoubleQuotes(href);
const preloadKey = `link[rel="preload"][as="${as}"][href="${limitedEscapedHref}"]`;
let key = preloadKey;
switch (as) {
Expand Down Expand Up @@ -476,8 +467,6 @@ export function getResource(
const styles = getResourcesFromRoot(resourceRoot).hoistableStyles;
let resource = styles.get(key);
if (!resource) {
// We asserted this above but Flow can't figure out that the type satisfies
const ownerDocument = getDocumentFromRoot(resourceRoot);
resource = {
type: 'style',
instance: null,
Expand Down Expand Up @@ -570,9 +559,8 @@ function styleTagPropsFromRawProps(
}

function getStyleKey(href: string) {
const limitedEscapedHref = escapeSelectorAttributeValueInsideDoubleQuotes(
href,
);
const limitedEscapedHref =
escapeSelectorAttributeValueInsideDoubleQuotes(href);
return `href="${limitedEscapedHref}"`;
}

Expand Down Expand Up @@ -609,9 +597,6 @@ function preloadStylesheet(
// There is no matching stylesheet instance in the Document.
// We will insert a preload now to kick off loading because
// we expect this stylesheet to commit
const limitedEscapedHref = escapeSelectorAttributeValueInsideDoubleQuotes(
preloadProps.href,
);
if (
null ===
ownerDocument.querySelector(getPreloadStylesheetSelectorFromKey(key))
Expand Down
29 changes: 14 additions & 15 deletions packages/react-dom-bindings/src/client/ReactDOMHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,7 @@ export const scheduleMicrotask: any =
? queueMicrotask
: typeof localPromise !== 'undefined'
? callback =>
localPromise
.resolve(null)
.then(callback)
.catch(handleErrorInNextTick)
localPromise.resolve(null).then(callback).catch(handleErrorInNextTick)
: scheduleTimeout; // TODO: Determine the best fallback here.

function handleErrorInNextTick(error: any) {
Expand Down Expand Up @@ -1591,8 +1588,8 @@ export function isHostHoistableType(
if (__DEV__) {
const hostContextDev: HostContextDev = (hostContext: any);
// We can only render resources when we are not within the host container context
outsideHostContainerContext = !hostContextDev.ancestorInfo
.containerTagInScope;
outsideHostContainerContext =
!hostContextDev.ancestorInfo.containerTagInScope;
namespace = hostContextDev.namespace;
} else {
const hostContextProd: HostContextProd = (hostContext: any);
Expand Down Expand Up @@ -1623,8 +1620,15 @@ export function isHostHoistableType(
);
}
case 'link': {
const {onLoad, onError} = props;
if (onLoad || onError) {
const {onLoad, onError, rel, href} = props;
if (
namespace === SVG_NAMESPACE ||
rel !== 'string' ||
href !== 'string' ||
href === '' ||
onLoad ||
onError
) {
if (__DEV__) {
if (outsideHostContainerContext) {
console.error(
Expand All @@ -1638,7 +1642,7 @@ export function isHostHoistableType(
}
switch (props.rel) {
case 'stylesheet': {
const {href, precedence, disabled} = props;
const {precedence, disabled} = props;
if (__DEV__) {
validateLinkPropsForStyleResource(props);
if (typeof precedence !== 'string') {
Expand All @@ -1650,12 +1654,7 @@ export function isHostHoistableType(
}
}
}
return (
namespace !== SVG_NAMESPACE &&
typeof href === 'string' &&
typeof precedence === 'string' &&
disabled == null
);
return typeof precedence === 'string' && disabled == null;
}
default: {
return true;
Expand Down
Loading

0 comments on commit 607f54d

Please sign in to comment.