File tree 4 files changed +46
-0
lines changed
4 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -275,6 +275,14 @@ export interface HTMLDimensions {
275
275
// @public
276
276
export type HTMLDimensionsImplementation = ' resize' | ' mutation' | ' polling' ;
277
277
278
+ // @public
279
+ export const InjectStyleFeature: FeatureClass <InjectStyleFeatureOptions >;
280
+
281
+ // @public
282
+ export interface InjectStyleFeatureOptions {
283
+ css: string ;
284
+ }
285
+
278
286
// @public
279
287
export interface LinkPressOptions {
280
288
ignoreHashChange? : boolean ;
Original file line number Diff line number Diff line change
1
+ import injectStyleScript from './InjectStyleFeature.webjs' ;
2
+ import FeatureBuilder from '../FeatureBuilder' ;
3
+ import type { FeatureClass } from '../Feature' ;
4
+
5
+ /**
6
+ * An object describing options for the inject style feature.
7
+ *
8
+ * @public
9
+ */
10
+ export interface InjectStyleFeatureOptions {
11
+ /**
12
+ * CSS markup to inject in a `<style>` element.
13
+ */
14
+ css : string ;
15
+ }
16
+
17
+ /**
18
+ * This feature injects a `<style>` element in the header of the page.
19
+ *
20
+ * @public
21
+ */
22
+ export const InjectStyleFeature : FeatureClass < InjectStyleFeatureOptions > = new FeatureBuilder < InjectStyleFeatureOptions > (
23
+ {
24
+ defaultOptions : { css : '' } ,
25
+ identifier : '@native-html/iframe-strip-body-spacing' ,
26
+ script : injectStyleScript
27
+ }
28
+ ) . build ( ) ;
Original file line number Diff line number Diff line change
1
+ function InjectStyleFeature(context) {
2
+ var options = context.options || {},
3
+ css = options.css || '',
4
+ head = document.head || document.getElementsByTagName('head')[0],
5
+ style = document.createElement('style');
6
+ style.type = 'text/css';
7
+ style.appendChild(document.createTextNode(css));
8
+ head.appendChild(style);
9
+ }
Original file line number Diff line number Diff line change @@ -5,3 +5,4 @@ export * from './HandleHashChangeFeature';
5
5
export * from './HandleVisualViewportFeature' ;
6
6
export * from './ForceResponsiveViewportFeature' ;
7
7
export * from './ForceElementSizeFeature' ;
8
+ export * from './InjectStyleFeature' ;
You can’t perform that action at this time.
0 commit comments