Skip to content

Commit

Permalink
chore(compiler/runtime): remove shadow dom shim (#4440)
Browse files Browse the repository at this point in the history
* chore(ci): enable ci for v4 dev (#4433)

this commit enables browserstack for the v4 development branch

* chore(compiler): remove dynamicImportShim (#4420)

* remove dynamicImportShim

* remove `dynamicImportShim` references from some tests

* add field removal to breaking changes

* chore(compiler): remove safari10 extras flag (#4421)

* remove safari10 extras flag

* remove `safari10` references in some tests

* add field removal to breaking changes

* chore(compiler/runtime): remove CSS var shim & patchEsm() (#4419)

* remove CSS var shim & patchEsm

* remove `cssVarShim` references from some tests

* remove some errant code

* add field removal to breaking changes

* fix build error

* 🎬 v4.0.0-beta.0

* remove public-facing shadowDomShim option

* missed one

* update todo comments

---------

Co-authored-by: Ryan Waskiewicz <[email protected]>
  • Loading branch information
tanner-reits and rwaskiewicz authored Jun 1, 2023
1 parent ad67a2d commit 8ecdec9
Show file tree
Hide file tree
Showing 22 changed files with 23 additions and 37 deletions.
8 changes: 8 additions & 0 deletions BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ for use at runtime. For Stencil v4.0.0 this field and corresponding behavior has
If `extras.__deprecated__safari10` is set to `true` the Stencil runtime will patch ES module
support for Safari 10. In Stencil v4.0.0 this field and corresponding behavior has been removed.

##### `__deprecated__shadowDomShim`

If `extras.__deprecated__shadowDomShim` is set to `true` the Stencil runtime will check
whether a shim for [shadow
DOM](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM)
is needed in the current browser, and include one if so. For Stencil v4.0.0
this field and its corresponding behavior has been removed.

## Stencil v3.0.0

* [General](#general)
Expand Down
2 changes: 1 addition & 1 deletion src/app-data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const BUILD: BuildConditionals = {
hydratedClass: true,
scriptDataOpts: false,
scopedSlotTextContentFix: false,
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
shadowDomShim: false,
slotChildNodesFix: false,
invisiblePrehydration: true,
Expand Down
2 changes: 1 addition & 1 deletion src/client/client-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const setPlatformHelpers = (helpers: {
};

export const supportsShadow =
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
BUILD.shadowDomShim && BUILD.shadowDom
? /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
: true;
Expand Down
4 changes: 1 addition & 3 deletions src/compiler/app-core/app-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,9 @@ export const updateBuildConditionals = (config: Config, b: BuildConditionals) =>
b.lifecycleDOMEvents = !!(b.isDebug || config._isTesting || config.extras.lifecycleDOMEvents);
b.scopedSlotTextContentFix = !!config.extras.scopedSlotTextContentFix;
b.scriptDataOpts = config.extras.scriptDataOpts;
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
b.shadowDomShim = config.extras.__deprecated__shadowDomShim;
b.attachStyles = true;
b.invisiblePrehydration = typeof config.invisiblePrehydration === 'undefined' ? true : config.invisiblePrehydration;
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
if (b.shadowDomShim) {
b.slotRelocation = b.slot;
}
Expand Down
2 changes: 0 additions & 2 deletions src/compiler/config/test/validate-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,6 @@ describe('validation', () => {
expect(config.extras.cloneNodeFix).toBe(false);
expect(config.extras.lifecycleDOMEvents).toBe(false);
expect(config.extras.scriptDataOpts).toBe(false);
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
expect(config.extras.__deprecated__shadowDomShim).toBe(false);
expect(config.extras.slotChildNodesFix).toBe(false);
expect(config.extras.initializeNextTick).toBe(false);
expect(config.extras.tagNameTransform).toBe(false);
Expand Down
2 changes: 0 additions & 2 deletions src/compiler/config/validate-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ export const validateConfig = (
validatedConfig.extras.cloneNodeFix = !!validatedConfig.extras.cloneNodeFix;
validatedConfig.extras.lifecycleDOMEvents = !!validatedConfig.extras.lifecycleDOMEvents;
validatedConfig.extras.scriptDataOpts = !!validatedConfig.extras.scriptDataOpts;
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
validatedConfig.extras.__deprecated__shadowDomShim = !!validatedConfig.extras.__deprecated__shadowDomShim;
validatedConfig.extras.slotChildNodesFix = !!validatedConfig.extras.slotChildNodesFix;
validatedConfig.extras.initializeNextTick = !!validatedConfig.extras.initializeNextTick;
validatedConfig.extras.tagNameTransform = !!validatedConfig.extras.tagNameTransform;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const getHydrateBuildConditionals = (config: d.ValidatedConfig, cmps: d.Componen
build.cloneNodeFix = false;
build.appendChildSlotFix = false;
build.slotChildNodesFix = false;
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
build.shadowDomShim = false;

return build;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const getHydrateBuildConditionals = (cmps: d.ComponentCompilerMeta[]) =>
build.slotChildNodesFix = false;
build.cloneNodeFix = false;
build.cssAnnotations = true;
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
build.shadowDomShim = true;
build.hydratedAttribute = false;
build.hydratedClass = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const addHydrateRuntimeCmpMeta = (classMembers: ts.ClassElement[], cmp: d
};
// We always need shadow-dom shim in hydrate runtime
if (cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) {
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
cmpMeta.$flags$ |= CMP_FLAGS.needsShadowDomShim;
}
const staticMember = createStaticGetter('cmpMeta', convertValueToLiteral(cmpMeta));
Expand Down
2 changes: 1 addition & 1 deletion src/declarations/stencil-private.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export interface BuildConditionals extends Partial<BuildFeatures> {
hydratedClass?: boolean;
initializeNextTick?: boolean;
scriptDataOpts?: boolean;
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
shadowDomShim?: boolean;
asyncQueue?: boolean;
transformTagName?: boolean;
Expand Down
12 changes: 0 additions & 12 deletions src/declarations/stencil-public-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,18 +314,6 @@ export interface ConfigExtras {
*/
scopedSlotTextContentFix?: boolean;

// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
/**
* If enabled `true`, the runtime will check if the shadow dom shim is required. However,
* if it's determined that shadow dom is already natively supported by the browser then
* it does not request the shim. When set to `false` it will avoid all shadow dom tests.
* Defaults to `false`.
*
* @deprecated Since Stencil v3.0.0. IE 11, Edge <= 18, and old Safari versions
* are no longer supported.
*/
__deprecated__shadowDomShim?: boolean;

/**
* When a component is first attached to the DOM, this setting will wait a single tick before
* rendering. This works around an Angular issue, where Angular attaches the elements before
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/bootstrap-custom-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const proxyCustomElement = (Cstr: any, compactMeta: d.ComponentRuntimeMet
cmpMeta.$attrsToReflect$ = [];
}
if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) {
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
cmpMeta.$flags$ |= CMP_FLAGS.needsShadowDomShim;
}

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/bootstrap-lazy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const bootstrapLazy = (lazyBundles: d.LazyBundlesRuntimeData, options: d.
cmpMeta.$watchers$ = {};
}
if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) {
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
cmpMeta.$flags$ |= CMP_FLAGS.needsShadowDomShim;
}
const tagName =
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/connected-callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const connectedCallback = (elm: d.HostElement) => {
if (
BUILD.hydrateServerSide ||
((BUILD.slot || BUILD.shadowDom) &&
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
cmpMeta.$flags$ & (CMP_FLAGS.hasSlotRelocation | CMP_FLAGS.needsShadowDomShim))
) {
setContentReference(elm);
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/dom-extras.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const patchChildSlotNodes = (elm: any, cmpMeta: d.ComponentRuntimeMeta) =
return this[n];
}
}
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
if (cmpMeta.$flags$ & CMP_FLAGS.needsShadowDomShim) {
const childNodesFn = elm.__lookupGetter__('childNodes');

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/initialize-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const initializeComponent = async (
if (
!BUILD.hydrateServerSide &&
BUILD.shadowDom &&
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
BUILD.shadowDomShim &&
cmpMeta.$flags$ & CMP_FLAGS.needsShadowDomShim
) {
Expand Down
1 change: 0 additions & 1 deletion src/runtime/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ export const attachStyles = (hostRef: d.HostRef) => {
hostRef.$modeName$
);

// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & CMP_FLAGS.needsScopedEncapsulation) {
// only required when we're NOT using native shadow dom (slot)
// or this browser doesn't support native shadow dom
Expand Down
2 changes: 1 addition & 1 deletion src/testing/spec-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export async function newSpecPage(opts: NewSpecPageOptions): Promise<SpecPage> {
BUILD.hydrateClientSide = false;
}
BUILD.cloneNodeFix = false;
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
BUILD.shadowDomShim = false;
BUILD.attachStyles = !!opts.attachStyles;

Expand Down
4 changes: 2 additions & 2 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ export const enum CMP_FLAGS {
shadowDomEncapsulation = 1 << 0,
scopedCssEncapsulation = 1 << 1,
hasSlotRelocation = 1 << 2,
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
// Note that when we remove this field we should consider whether we need to
// retain a placeholder here, since if we want to have compatability between
// different versions of the runtime then we'll need to not shift the values
// of the other higher flags down
needsShadowDomShim = 1 << 3,
shadowDelegatesFocus = 1 << 4,
hasMode = 1 << 5,
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
needsScopedEncapsulation = scopedCssEncapsulation | needsShadowDomShim,
}

Expand Down
1 change: 0 additions & 1 deletion test/jest-spec-runner/stencil.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ export const config: Config = {
hydratedFlag: null,
extras: {
scriptDataOpts: false,
shadowDomShim: false,
},
};
1 change: 0 additions & 1 deletion test/karma/stencil.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export const config: Config = {
lifecycleDOMEvents: true,
scopedSlotTextContentFix: true,
scriptDataOpts: true,
shadowDomShim: true,
slotChildNodesFix: true,
},
devServer: {
Expand Down
1 change: 0 additions & 1 deletion test/todo-app/stencil.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ export const config: Config = {
hydratedFlag: null,
extras: {
scriptDataOpts: false,
shadowDomShim: false,
},
};

0 comments on commit 8ecdec9

Please sign in to comment.