802
// inserted without breaking hydration
803
export function isHydratable(type: string, props: Props): boolean {
804
if (enableFloat) {
805
- if (type === 'script') {
805
+ if (type === 'link') {
806
+ if (
807
+ (props: any).rel === 'stylesheet' &&
808
+ typeof (props: any).precedence !== 'string'
809
+ ) {
810
+ return true;
811
+ }
812
+ return false;
813
+ } else if (type === 'script') {
814
const {async, onLoad, onError} = (props: any);
815
return !(async && (onLoad || onError));
816
}
910
if (nodeType === ELEMENT_NODE) {
911
const element: Element = (node: any);
912
switch (element.tagName) {
913
+ case 'TITLE':
914
+ case 'META':
915
+ case 'BASE':
916
+ case 'HTML':
917
+ case 'HEAD':
918
+ case 'BODY': {
919
+ continue;
920
+ }
921
case 'LINK': {
922
const linkEl: HTMLLinkElement = (element: any);
907
- const rel = linkEl.rel;
923
+ // All links that are server rendered are resources except
924
+ // stylesheets that do not have a precedence
925
if (
909
- rel === 'preload' ||
910
- (rel === 'stylesheet' && linkEl.hasAttribute('data-precedence'))
926
+ linkEl.rel === 'stylesheet' &&
927
+ !linkEl.hasAttribute('data-precedence')
928
) {
912
- continue;
929
+ break;
930
}
914
- break;
931
+ continue;
932
}
933
case 'STYLE': {
934
const styleEl: HTMLStyleElement = (element: any);
944
}
945
break;
946
}
930
- case 'TITLE':
931
- case 'HTML':
932
- case 'HEAD':
933
- case 'BODY': {
934
- continue;
935
- }
947
}
948
break;
949
} else if (nodeType === TEXT_NODE) {
953
if (nodeType === ELEMENT_NODE) {
954
const element: Element = (node: any);
955
switch (element.tagName) {
956
+ case 'TITLE':
957
+ case 'META':
958
+ case 'BASE': {
959
+ continue;
960
+ }
961
case 'LINK': {
962
const linkEl: HTMLLinkElement = (element: any);
947
- const rel = linkEl.rel;
963
+ // All links that are server rendered are resources except
964
+ // stylesheets that do not have a precedence
965
if (
949
- rel === 'preload' ||
950
- (rel === 'stylesheet' && linkEl.hasAttribute('data-precedence'))
966
+ linkEl.rel === 'stylesheet' &&
967
+ !linkEl.hasAttribute('data-precedence')
968
) {
952
- continue;
969
+ break;
970
}
954
- break;
955
- }
956
- case 'TITLE': {
971
continue;
972
}
973
case 'STYLE': {