Best JavaScript code snippet using playwright-internal
main.js
Source:main.js
...5117 });5118 });5119 return target;5120}5121function exposePropsOnRenderContext(instance) {5122 const { ctx, propsOptions: [propsOptions] } = instance;5123 if (propsOptions) {5124 Object.keys(propsOptions).forEach((key) => {5125 Object.defineProperty(ctx, key, {5126 enumerable: true,5127 configurable: true,5128 get: () => instance.props[key],5129 set: NOOP5130 });5131 });5132 }5133}5134function exposeSetupStateOnRenderContext(instance) {5135 const { ctx, setupState } = instance;5136 Object.keys(toRaw(setupState)).forEach((key) => {5137 if (!setupState.__isScriptSetup) {5138 if (key[0] === "$" || key[0] === "_") {5139 warn2(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" which are reserved prefixes for Vue internals.`);5140 return;5141 }5142 Object.defineProperty(ctx, key, {5143 enumerable: true,5144 configurable: true,5145 get: () => setupState[key],5146 set: NOOP5147 });5148 }5149 });5150}5151var emptyAppContext = createAppContext();5152var uid$1 = 0;5153function createComponentInstance(vnode, parent, suspense) {5154 const type = vnode.type;5155 const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;5156 const instance = {5157 uid: uid$1++,5158 vnode,5159 type,5160 parent,5161 appContext,5162 root: null,5163 next: null,5164 subTree: null,5165 effect: null,5166 update: null,5167 scope: new EffectScope(true),5168 render: null,5169 proxy: null,5170 exposed: null,5171 exposeProxy: null,5172 withProxy: null,5173 provides: parent ? parent.provides : Object.create(appContext.provides),5174 accessCache: null,5175 renderCache: [],5176 components: null,5177 directives: null,5178 propsOptions: normalizePropsOptions(type, appContext),5179 emitsOptions: normalizeEmitsOptions(type, appContext),5180 emit: null,5181 emitted: null,5182 propsDefaults: EMPTY_OBJ,5183 inheritAttrs: type.inheritAttrs,5184 ctx: EMPTY_OBJ,5185 data: EMPTY_OBJ,5186 props: EMPTY_OBJ,5187 attrs: EMPTY_OBJ,5188 slots: EMPTY_OBJ,5189 refs: EMPTY_OBJ,5190 setupState: EMPTY_OBJ,5191 setupContext: null,5192 suspense,5193 suspenseId: suspense ? suspense.pendingId : 0,5194 asyncDep: null,5195 asyncResolved: false,5196 isMounted: false,5197 isUnmounted: false,5198 isDeactivated: false,5199 bc: null,5200 c: null,5201 bm: null,5202 m: null,5203 bu: null,5204 u: null,5205 um: null,5206 bum: null,5207 da: null,5208 a: null,5209 rtg: null,5210 rtc: null,5211 ec: null,5212 sp: null5213 };5214 if (true) {5215 instance.ctx = createDevRenderContext(instance);5216 } else {5217 instance.ctx = { _: instance };5218 }5219 instance.root = parent ? parent.root : instance;5220 instance.emit = emit$1.bind(null, instance);5221 if (vnode.ce) {5222 vnode.ce(instance);5223 }5224 return instance;5225}5226var currentInstance = null;5227var getCurrentInstance = () => currentInstance || currentRenderingInstance;5228var setCurrentInstance = (instance) => {5229 currentInstance = instance;5230 instance.scope.on();5231};5232var unsetCurrentInstance = () => {5233 currentInstance && currentInstance.scope.off();5234 currentInstance = null;5235};5236var isBuiltInTag = /* @__PURE__ */ makeMap("slot,component");5237function validateComponentName(name, config) {5238 const appIsNativeTag = config.isNativeTag || NO;5239 if (isBuiltInTag(name) || appIsNativeTag(name)) {5240 warn2("Do not use built-in or reserved HTML elements as component id: " + name);5241 }5242}5243function isStatefulComponent(instance) {5244 return instance.vnode.shapeFlag & 4;5245}5246var isInSSRComponentSetup = false;5247function setupComponent(instance, isSSR = false) {5248 isInSSRComponentSetup = isSSR;5249 const { props, children } = instance.vnode;5250 const isStateful = isStatefulComponent(instance);5251 initProps(instance, props, isStateful, isSSR);5252 initSlots(instance, children);5253 const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : void 0;5254 isInSSRComponentSetup = false;5255 return setupResult;5256}5257function setupStatefulComponent(instance, isSSR) {5258 const Component = instance.type;5259 if (true) {5260 if (Component.name) {5261 validateComponentName(Component.name, instance.appContext.config);5262 }5263 if (Component.components) {5264 const names = Object.keys(Component.components);5265 for (let i = 0; i < names.length; i++) {5266 validateComponentName(names[i], instance.appContext.config);5267 }5268 }5269 if (Component.directives) {5270 const names = Object.keys(Component.directives);5271 for (let i = 0; i < names.length; i++) {5272 validateDirectiveName(names[i]);5273 }5274 }5275 if (Component.compilerOptions && isRuntimeOnly()) {5276 warn2(`"compilerOptions" is only supported when using a build of Vue that includes the runtime compiler. Since you are using a runtime-only build, the options should be passed via your build tool config instead.`);5277 }5278 }5279 instance.accessCache = Object.create(null);5280 instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));5281 if (true) {5282 exposePropsOnRenderContext(instance);5283 }5284 const { setup } = Component;5285 if (setup) {5286 const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null;5287 setCurrentInstance(instance);5288 pauseTracking();5289 const setupResult = callWithErrorHandling(setup, instance, 0, [true ? shallowReadonly(instance.props) : instance.props, setupContext]);5290 resetTracking();5291 unsetCurrentInstance();5292 if (isPromise(setupResult)) {5293 setupResult.then(unsetCurrentInstance, unsetCurrentInstance);5294 if (isSSR) {5295 return setupResult.then((resolvedResult) => {5296 handleSetupResult(instance, resolvedResult, isSSR);...
size-check.global.js
Source:size-check.global.js
...4447 });4448 return target;4449 }4450 // dev only4451 function exposePropsOnRenderContext(instance) {4452 const { ctx, type: { props: propsOptions } } = instance;4453 if (propsOptions) {4454 Object.keys(normalizePropsOptions(propsOptions)[0]).forEach(key => {4455 Object.defineProperty(ctx, key, {4456 enumerable: true,4457 configurable: true,4458 get: () => instance.props[key],4459 set: NOOP4460 });4461 });4462 }4463 }4464 // dev only4465 function exposeSetupStateOnRenderContext(instance) {4466 const { ctx, setupState } = instance;4467 Object.keys(toRaw(setupState)).forEach(key => {4468 Object.defineProperty(ctx, key, {4469 enumerable: true,4470 configurable: true,4471 get: () => setupState[key],4472 set: NOOP4473 });4474 });4475 }4476 const emptyAppContext = createAppContext();4477 let uid$1 = 0;4478 function createComponentInstance(vnode, parent, suspense) {4479 // inherit parent app context - or - if root, adopt from root vnode4480 const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;4481 const instance = {4482 uid: uid$1++,4483 vnode,4484 parent,4485 appContext,4486 type: vnode.type,4487 root: null,4488 next: null,4489 subTree: null,4490 update: null,4491 render: null,4492 proxy: null,4493 withProxy: null,4494 effects: null,4495 provides: parent ? parent.provides : Object.create(appContext.provides),4496 accessCache: null,4497 renderCache: [],4498 // state4499 ctx: EMPTY_OBJ,4500 data: EMPTY_OBJ,4501 props: EMPTY_OBJ,4502 attrs: EMPTY_OBJ,4503 slots: EMPTY_OBJ,4504 refs: EMPTY_OBJ,4505 setupState: EMPTY_OBJ,4506 setupContext: null,4507 // per-instance asset storage (mutable during options resolution)4508 components: Object.create(appContext.components),4509 directives: Object.create(appContext.directives),4510 // suspense related4511 suspense,4512 asyncDep: null,4513 asyncResolved: false,4514 // lifecycle hooks4515 // not using enums here because it results in computed properties4516 isMounted: false,4517 isUnmounted: false,4518 isDeactivated: false,4519 bc: null,4520 c: null,4521 bm: null,4522 m: null,4523 bu: null,4524 u: null,4525 um: null,4526 bum: null,4527 da: null,4528 a: null,4529 rtg: null,4530 rtc: null,4531 ec: null,4532 emit: null // to be set immediately4533 };4534 {4535 instance.ctx = createRenderContext(instance);4536 }4537 instance.root = parent ? parent.root : instance;4538 instance.emit = emit.bind(null, instance);4539 return instance;4540 }4541 let currentInstance = null;4542 const setCurrentInstance = (instance) => {4543 currentInstance = instance;4544 };4545 const isBuiltInTag = /*#__PURE__*/ makeMap('slot,component');4546 function validateComponentName(name, config) {4547 const appIsNativeTag = config.isNativeTag || NO;4548 if (isBuiltInTag(name) || appIsNativeTag(name)) {4549 warn('Do not use built-in or reserved HTML elements as component id: ' + name);4550 }4551 }4552 let isInSSRComponentSetup = false;4553 function setupComponent(instance, isSSR = false) {4554 isInSSRComponentSetup = isSSR;4555 const { props, children, shapeFlag } = instance.vnode;4556 const isStateful = shapeFlag & 4 /* STATEFUL_COMPONENT */;4557 initProps(instance, props, isStateful, isSSR);4558 initSlots(instance, children);4559 const setupResult = isStateful4560 ? setupStatefulComponent(instance, isSSR)4561 : undefined;4562 isInSSRComponentSetup = false;4563 return setupResult;4564 }4565 function setupStatefulComponent(instance, isSSR) {4566 const Component = instance.type;4567 {4568 if (Component.name) {4569 validateComponentName(Component.name, instance.appContext.config);4570 }4571 if (Component.components) {4572 const names = Object.keys(Component.components);4573 for (let i = 0; i < names.length; i++) {4574 validateComponentName(names[i], instance.appContext.config);4575 }4576 }4577 if (Component.directives) {4578 const names = Object.keys(Component.directives);4579 for (let i = 0; i < names.length; i++) {4580 validateDirectiveName(names[i]);4581 }4582 }4583 }4584 // 0. create render proxy property access cache4585 instance.accessCache = {};4586 // 1. create public instance / render proxy4587 instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);4588 {4589 exposePropsOnRenderContext(instance);4590 }4591 // 2. call setup()4592 const { setup } = Component;4593 if (setup) {4594 const setupContext = (instance.setupContext =4595 setup.length > 1 ? createSetupContext(instance) : null);4596 currentInstance = instance;4597 pauseTracking();4598 const setupResult = callWithErrorHandling(setup, instance, 0 /* SETUP_FUNCTION */, [ shallowReadonly(instance.props) , setupContext]);4599 resetTracking();4600 currentInstance = null;4601 if (isPromise(setupResult)) {4602 if (isSSR) {4603 // return the promise so server-renderer can wait on it
...
bundle.esm.js
Source:bundle.esm.js
...4625 });4626 return target;4627}4628// dev only4629function exposePropsOnRenderContext(instance) {4630 const { ctx, type: { props: propsOptions } } = instance;4631 if (propsOptions) {4632 Object.keys(normalizePropsOptions(propsOptions)[0]).forEach(key => {4633 Object.defineProperty(ctx, key, {4634 enumerable: true,4635 configurable: true,4636 get: () => instance.props[key],4637 set: NOOP4638 });4639 });4640 }4641}4642// dev only4643function exposeSetupStateOnRenderContext(instance) {4644 const { ctx, setupState } = instance;4645 Object.keys(toRaw(setupState)).forEach(key => {4646 Object.defineProperty(ctx, key, {4647 enumerable: true,4648 configurable: true,4649 get: () => setupState[key],4650 set: NOOP4651 });4652 });4653}4654const emptyAppContext = createAppContext();4655let uid$1 = 0;4656function createComponentInstance(vnode, parent, suspense) {4657 // inherit parent app context - or - if root, adopt from root vnode4658 const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;4659 const instance = {4660 uid: uid$1++,4661 vnode,4662 parent,4663 appContext,4664 type: vnode.type,4665 root: null,4666 next: null,4667 subTree: null,4668 update: null,4669 render: null,4670 proxy: null,4671 withProxy: null,4672 effects: null,4673 provides: parent ? parent.provides : Object.create(appContext.provides),4674 accessCache: null,4675 renderCache: [],4676 // state4677 ctx: EMPTY_OBJ,4678 data: EMPTY_OBJ,4679 props: EMPTY_OBJ,4680 attrs: EMPTY_OBJ,4681 slots: EMPTY_OBJ,4682 refs: EMPTY_OBJ,4683 setupState: EMPTY_OBJ,4684 setupContext: null,4685 // per-instance asset storage (mutable during options resolution)4686 components: Object.create(appContext.components),4687 directives: Object.create(appContext.directives),4688 // suspense related4689 suspense,4690 asyncDep: null,4691 asyncResolved: false,4692 // lifecycle hooks4693 // not using enums here because it results in computed properties4694 isMounted: false,4695 isUnmounted: false,4696 isDeactivated: false,4697 bc: null,4698 c: null,4699 bm: null,4700 m: null,4701 bu: null,4702 u: null,4703 um: null,4704 bum: null,4705 da: null,4706 a: null,4707 rtg: null,4708 rtc: null,4709 ec: null,4710 emit: null // to be set immediately4711 };4712 {4713 instance.ctx = createRenderContext(instance);4714 }4715 instance.root = parent ? parent.root : instance;4716 instance.emit = emit.bind(null, instance);4717 return instance;4718}4719let currentInstance = null;4720const setCurrentInstance = (instance) => {4721 currentInstance = instance;4722};4723const isBuiltInTag = /*#__PURE__*/ makeMap('slot,component');4724function validateComponentName(name, config) {4725 const appIsNativeTag = config.isNativeTag || NO;4726 if (isBuiltInTag(name) || appIsNativeTag(name)) {4727 warn('Do not use built-in or reserved HTML elements as component id: ' + name);4728 }4729}4730let isInSSRComponentSetup = false;4731function setupComponent(instance, isSSR = false) {4732 isInSSRComponentSetup = isSSR;4733 const { props, children, shapeFlag } = instance.vnode;4734 const isStateful = shapeFlag & 4 /* STATEFUL_COMPONENT */;4735 initProps(instance, props, isStateful, isSSR);4736 initSlots(instance, children);4737 const setupResult = isStateful4738 ? setupStatefulComponent(instance, isSSR)4739 : undefined;4740 isInSSRComponentSetup = false;4741 return setupResult;4742}4743function setupStatefulComponent(instance, isSSR) {4744 const Component = instance.type;4745 {4746 if (Component.name) {4747 validateComponentName(Component.name, instance.appContext.config);4748 }4749 if (Component.components) {4750 const names = Object.keys(Component.components);4751 for (let i = 0; i < names.length; i++) {4752 validateComponentName(names[i], instance.appContext.config);4753 }4754 }4755 if (Component.directives) {4756 const names = Object.keys(Component.directives);4757 for (let i = 0; i < names.length; i++) {4758 validateDirectiveName(names[i]);4759 }4760 }4761 }4762 // 0. create render proxy property access cache4763 instance.accessCache = {};4764 // 1. create public instance / render proxy4765 // also mark it raw so it's never observed4766 instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);4767 {4768 exposePropsOnRenderContext(instance);4769 }4770 // 2. call setup()4771 const { setup } = Component;4772 if (setup) {4773 const setupContext = (instance.setupContext =4774 setup.length > 1 ? createSetupContext(instance) : null);4775 currentInstance = instance;4776 pauseTracking();4777 const setupResult = callWithErrorHandling(setup, instance, 0 /* SETUP_FUNCTION */, [ shallowReadonly(instance.props) , setupContext]);4778 resetTracking();4779 currentInstance = null;4780 if (isPromise(setupResult)) {4781 if (isSSR) {4782 // return the promise so server-renderer can wait on it
...
vendor.js
Source:vendor.js
...3068 });3069 });3070 return target;3071}3072function exposePropsOnRenderContext(instance) {3073 const { ctx, propsOptions: [propsOptions] } = instance;3074 if (propsOptions) {3075 Object.keys(propsOptions).forEach((key) => {3076 Object.defineProperty(ctx, key, {3077 enumerable: true,3078 configurable: true,3079 get: () => instance.props[key],3080 set: NOOP3081 });3082 });3083 }3084}3085function exposeSetupStateOnRenderContext(instance) {3086 const { ctx, setupState } = instance;3087 Object.keys(toRaw(setupState)).forEach((key) => {3088 if (!setupState.__isScriptSetup) {3089 if (key[0] === "$" || key[0] === "_") {3090 warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" which are reserved prefixes for Vue internals.`);3091 return;3092 }3093 Object.defineProperty(ctx, key, {3094 enumerable: true,3095 configurable: true,3096 get: () => setupState[key],3097 set: NOOP3098 });3099 }3100 });3101}3102const emptyAppContext = createAppContext();3103let uid$1 = 0;3104function createComponentInstance(vnode, parent, suspense) {3105 const type = vnode.type;3106 const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;3107 const instance = {3108 uid: uid$1++,3109 vnode,3110 type,3111 parent,3112 appContext,3113 root: null,3114 next: null,3115 subTree: null,3116 effect: null,3117 update: null,3118 scope: new EffectScope(true),3119 render: null,3120 proxy: null,3121 exposed: null,3122 exposeProxy: null,3123 withProxy: null,3124 provides: parent ? parent.provides : Object.create(appContext.provides),3125 accessCache: null,3126 renderCache: [],3127 components: null,3128 directives: null,3129 propsOptions: normalizePropsOptions(type, appContext),3130 emitsOptions: normalizeEmitsOptions(type, appContext),3131 emit: null,3132 emitted: null,3133 propsDefaults: EMPTY_OBJ,3134 inheritAttrs: type.inheritAttrs,3135 ctx: EMPTY_OBJ,3136 data: EMPTY_OBJ,3137 props: EMPTY_OBJ,3138 attrs: EMPTY_OBJ,3139 slots: EMPTY_OBJ,3140 refs: EMPTY_OBJ,3141 setupState: EMPTY_OBJ,3142 setupContext: null,3143 suspense,3144 suspenseId: suspense ? suspense.pendingId : 0,3145 asyncDep: null,3146 asyncResolved: false,3147 isMounted: false,3148 isUnmounted: false,3149 isDeactivated: false,3150 bc: null,3151 c: null,3152 bm: null,3153 m: null,3154 bu: null,3155 u: null,3156 um: null,3157 bum: null,3158 da: null,3159 a: null,3160 rtg: null,3161 rtc: null,3162 ec: null,3163 sp: null3164 };3165 {3166 instance.ctx = createDevRenderContext(instance);3167 }3168 instance.root = parent ? parent.root : instance;3169 instance.emit = emit$1.bind(null, instance);3170 if (vnode.ce) {3171 vnode.ce(instance);3172 }3173 return instance;3174}3175let currentInstance = null;3176const getCurrentInstance = () => currentInstance || currentRenderingInstance;3177const setCurrentInstance = (instance) => {3178 currentInstance = instance;3179 instance.scope.on();3180};3181const unsetCurrentInstance = () => {3182 currentInstance && currentInstance.scope.off();3183 currentInstance = null;3184};3185const isBuiltInTag = /* @__PURE__ */ makeMap("slot,component");3186function validateComponentName(name, config) {3187 const appIsNativeTag = config.isNativeTag || NO;3188 if (isBuiltInTag(name) || appIsNativeTag(name)) {3189 warn$1("Do not use built-in or reserved HTML elements as component id: " + name);3190 }3191}3192function isStatefulComponent(instance) {3193 return instance.vnode.shapeFlag & 4;3194}3195let isInSSRComponentSetup = false;3196function setupComponent(instance, isSSR = false) {3197 isInSSRComponentSetup = isSSR;3198 const { props } = instance.vnode;3199 const isStateful = isStatefulComponent(instance);3200 initProps$1(instance, props, isStateful, isSSR);3201 const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : void 0;3202 isInSSRComponentSetup = false;3203 return setupResult;3204}3205function setupStatefulComponent(instance, isSSR) {3206 const Component2 = instance.type;3207 {3208 if (Component2.name) {3209 validateComponentName(Component2.name, instance.appContext.config);3210 }3211 if (Component2.components) {3212 const names = Object.keys(Component2.components);3213 for (let i = 0; i < names.length; i++) {3214 validateComponentName(names[i], instance.appContext.config);3215 }3216 }3217 if (Component2.directives) {3218 const names = Object.keys(Component2.directives);3219 for (let i = 0; i < names.length; i++) {3220 validateDirectiveName(names[i]);3221 }3222 }3223 if (Component2.compilerOptions && isRuntimeOnly()) {3224 warn$1(`"compilerOptions" is only supported when using a build of Vue that includes the runtime compiler. Since you are using a runtime-only build, the options should be passed via your build tool config instead.`);3225 }3226 }3227 instance.accessCache = Object.create(null);3228 instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));3229 {3230 exposePropsOnRenderContext(instance);3231 }3232 const { setup } = Component2;3233 if (setup) {3234 const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null;3235 setCurrentInstance(instance);3236 pauseTracking();3237 const setupResult = callWithErrorHandling(setup, instance, 0, [shallowReadonly(instance.props), setupContext]);3238 resetTracking();3239 unsetCurrentInstance();3240 if (isPromise(setupResult)) {3241 setupResult.then(unsetCurrentInstance, unsetCurrentInstance);3242 {3243 warn$1(`setup() returned a Promise, but the version of Vue you are using does not support it yet.`);3244 }...
vue.runtime.esm.js
Source:vue.runtime.esm.js
...2725 });2726 return target;2727}2728// dev only2729function exposePropsOnRenderContext(instance) {2730 const { ctx, propsOptions: [propsOptions] } = instance;2731 if (propsOptions) {2732 Object.keys(propsOptions).forEach(key => {2733 Object.defineProperty(ctx, key, {2734 enumerable: true,2735 configurable: true,2736 get: () => instance.props[key],2737 set: NOOP2738 });2739 });2740 }2741}2742// dev only2743function exposeSetupStateOnRenderContext(instance) {2744 const { ctx, setupState } = instance;2745 Object.keys(toRaw(setupState)).forEach(key => {2746 if (key[0] === '$' || key[0] === '_') {2747 warn(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +2748 `which are reserved prefixes for Vue internals.`);2749 return;2750 }2751 Object.defineProperty(ctx, key, {2752 enumerable: true,2753 configurable: true,2754 get: () => setupState[key],2755 set: NOOP2756 });2757 });2758}2759const emptyAppContext = createAppContext();2760let uid$2 = 0;2761function createComponentInstance(vnode, parent, suspense) {2762 const type = vnode.type;2763 // inherit parent app context - or - if root, adopt from root vnode2764 const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;2765 const instance = {2766 uid: uid$2++,2767 vnode,2768 type,2769 parent,2770 appContext,2771 root: null,2772 next: null,2773 subTree: null,2774 update: null,2775 render: null,2776 proxy: null,2777 withProxy: null,2778 effects: null,2779 provides: parent ? parent.provides : Object.create(appContext.provides),2780 accessCache: null,2781 renderCache: [],2782 // local resovled assets2783 components: null,2784 directives: null,2785 // resolved props and emits options2786 propsOptions: normalizePropsOptions(type, appContext),2787 emitsOptions: normalizeEmitsOptions(type, appContext),2788 // emit2789 emit: null,2790 emitted: null,2791 // state2792 ctx: EMPTY_OBJ,2793 data: EMPTY_OBJ,2794 props: EMPTY_OBJ,2795 attrs: EMPTY_OBJ,2796 slots: EMPTY_OBJ,2797 refs: EMPTY_OBJ,2798 setupState: EMPTY_OBJ,2799 setupContext: null,2800 // suspense related2801 suspense,2802 suspenseId: suspense ? suspense.pendingId : 0,2803 asyncDep: null,2804 asyncResolved: false,2805 // lifecycle hooks2806 // not using enums here because it results in computed properties2807 isMounted: false,2808 isUnmounted: false,2809 isDeactivated: false,2810 bc: null,2811 c: null,2812 bm: null,2813 m: null,2814 bu: null,2815 u: null,2816 um: null,2817 bum: null,2818 da: null,2819 a: null,2820 rtg: null,2821 rtc: null,2822 ec: null2823 };2824 if ((process.env.NODE_ENV !== 'production')) {2825 instance.ctx = createRenderContext(instance);2826 }2827 else {2828 instance.ctx = { _: instance };2829 }2830 instance.root = parent ? parent.root : instance;2831 instance.emit = emit.bind(null, instance);2832 if ((process.env.NODE_ENV !== 'production') || false) ;2833 return instance;2834}2835let currentInstance = null;2836const setCurrentInstance = (instance) => {2837 currentInstance = instance;2838};2839const isBuiltInTag = /*#__PURE__*/ makeMap('slot,component');2840function validateComponentName(name, config) {2841 const appIsNativeTag = config.isNativeTag || NO;2842 if (isBuiltInTag(name) || appIsNativeTag(name)) {2843 warn('Do not use built-in or reserved HTML elements as component id: ' + name);2844 }2845}2846let isInSSRComponentSetup = false;2847function setupComponent(instance, isSSR = false) {2848 isInSSRComponentSetup = isSSR;2849 const { props, /* children, */ shapeFlag } = instance.vnode;2850 const isStateful = shapeFlag & 4 /* STATEFUL_COMPONENT */;2851 initProps(instance, props, isStateful, isSSR);2852 // initSlots(instance, children) // fixed by xxxxxx2853 const setupResult = isStateful2854 ? setupStatefulComponent(instance, isSSR)2855 : undefined;2856 isInSSRComponentSetup = false;2857 return setupResult;2858}2859function setupStatefulComponent(instance, isSSR) {2860 const Component = instance.type;2861 if ((process.env.NODE_ENV !== 'production')) {2862 if (Component.name) {2863 validateComponentName(Component.name, instance.appContext.config);2864 }2865 if (Component.components) {2866 const names = Object.keys(Component.components);2867 for (let i = 0; i < names.length; i++) {2868 validateComponentName(names[i], instance.appContext.config);2869 }2870 }2871 if (Component.directives) {2872 const names = Object.keys(Component.directives);2873 for (let i = 0; i < names.length; i++) {2874 validateDirectiveName(names[i]);2875 }2876 }2877 }2878 // 0. create render proxy property access cache2879 instance.accessCache = {};2880 // 1. create public instance / render proxy2881 // also mark it raw so it's never observed2882 instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);2883 if ((process.env.NODE_ENV !== 'production')) {2884 exposePropsOnRenderContext(instance);2885 }2886 // 2. call setup()2887 const { setup } = Component;2888 if (setup) {2889 const setupContext = (instance.setupContext =2890 setup.length > 1 ? createSetupContext(instance) : null);2891 currentInstance = instance;2892 pauseTracking();2893 const setupResult = callWithErrorHandling(setup, instance, 0 /* SETUP_FUNCTION */, [(process.env.NODE_ENV !== 'production') ? shallowReadonly(instance.props) : instance.props, setupContext]);2894 resetTracking();2895 currentInstance = null;2896 if (isPromise(setupResult)) {2897 if (isSSR) {2898 // return the promise so server-renderer can wait on it
...
render.js
Source:render.js
...843 // 1. create public instance / render proxy844 // also mark it raw so it's never observed845 instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);846 {847 exposePropsOnRenderContext(instance);848 }849 // 2. call setup()850 const { setup } = Component;851 if (setup) {852 const setupContext = (instance.setupContext =853 setup.length > 1 ? createSetupContext(instance) : null);854 currentInstance = instance;855 pauseTracking();856 const setupResult = callWithErrorHandling(setup, instance, 0 /* SETUP_FUNCTION */, [ shallowReadonly(instance.props) , setupContext]);857 resetTracking();858 currentInstance = null;859 if (isPromise(setupResult)) {860 if (isSSR) {861 // return the promise so server-renderer can wait on it862 return setupResult.then((resolvedResult) => {863 handleSetupResult(instance, resolvedResult);864 });865 }866 else {867 // async setup returned Promise.868 // bail here and wait for re-entry.869 instance.asyncDep = setupResult;870 }871 }872 else {873 handleSetupResult(instance, setupResult);874 }875 }876 else {877 finishComponentSetup(instance);878 }879 }880 // dev only881 function exposePropsOnRenderContext(instance) {882 const { ctx, propsOptions: [propsOptions] } = instance;883 if (propsOptions) {884 Object.keys(propsOptions).forEach(key => {885 Object.defineProperty(ctx, key, {886 enumerable: true,887 configurable: true,888 get: () => instance.props[key],889 set: NOOP890 });891 });892 }893 }894 function handleSetupResult(instance, setupResult, isSSR) {895 if (isFunction(setupResult)) {...
note.js
Source:note.js
...2017 // 1. create public instance / render proxy2018 // also mark it raw so it's never observed2019 instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);2020 {2021 exposePropsOnRenderContext(instance);2022 }2023 // 2. call setup()2024 const { setup } = Component;2025 if (setup) {2026 const setupContext = (instance.setupContext =2027 setup.length > 1 ? createSetupContext(instance) : null);2028 currentInstance = instance;2029 pauseTracking();2030 const setupResult = callWithErrorHandling(setup, instance, 0 /* SETUP_FUNCTION */, [ shallowReadonly(instance.props) , setupContext]);2031 resetTracking();2032 currentInstance = null;2033 if (isPromise(setupResult)) {2034 if (isSSR) {2035 // return the promise so server-renderer can wait on it2036 return setupResult.then((resolvedResult) => {2037 handleSetupResult(instance, resolvedResult);2038 });2039 }2040 else {2041 // async setup returned Promise.2042 // bail here and wait for re-entry.2043 instance.asyncDep = setupResult;2044 }2045 }2046 else {2047 handleSetupResult(instance, setupResult);2048 }2049 }2050 else {2051 finishComponentSetup(instance);2052 }2053}2054/**2055 * åå§åslot2056 * 2057 */2058const initSlots = (instance, children) => {2059 if (instance.vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {2060 const type = children._;2061 if (type) {2062 instance.slots = children;2063 // make compiler marker non-enumerable2064 def(children, '_', type);2065 }2066 else {2067 normalizeObjectSlots(children, (instance.slots = {}));2068 }2069 }2070 else {2071 instance.slots = {};2072 if (children) {2073 normalizeVNodeSlots(instance, children);2074 }2075 }2076 def(instance.slots, InternalObjectKey, 1);2077};2078const normalizeObjectSlots = (rawSlots, slots) => {2079 const ctx = rawSlots._ctx;2080 for (const key in rawSlots) {2081 if (isInternalKey(key))2082 continue;2083 const value = rawSlots[key];2084 if (isFunction(value)) {2085 slots[key] = normalizeSlot(key, value, ctx);2086 }2087 else if (value != null) {2088 {2089 warn(`Non-function value encountered for slot "${key}". ` +2090 `Prefer function slots for better performance.`);2091 }2092 const normalized = normalizeSlotValue(value);2093 slots[key] = () => normalized;2094 }2095 }2096};2097const normalizeVNodeSlots = (instance, children) => {2098 if ( !isKeepAlive(instance.vnode)) {2099 warn(`Non-function value encountered for default slot. ` +2100 `Prefer function slots for better performance.`);2101 }2102 const normalized = normalizeSlotValue(children);2103 instance.slots.default = () => normalized;2104};2105const normalizeSlotValue = (value) => isArray(value)2106 ? value.map(normalizeVNode)2107 : [normalizeVNode(value)];2108const normalizeSlot = (key, rawSlot, ctx) => withCtx((props) => {2109 if ( currentInstance) {2110 warn(`Slot "${key}" invoked outside of the render function: ` +2111 `this will not track dependencies used in the slot. ` +2112 `Invoke the slot function inside the render function instead.`);2113 }2114 return normalizeSlotValue(rawSlot(props));2115}, ctx);2116function normalizeVNode(child) {2117 if (child == null || typeof child === 'boolean') {2118 // empty placeholder2119 return createVNode(Comment);2120 }2121 else if (isArray(child)) {2122 // fragment2123 return createVNode(Fragment, null, child);2124 }2125 else if (typeof child === 'object') {2126 // already vnode, this should be the most common since compiled templates2127 // always produce all-vnode children arrays2128 return child.el === null ? child : cloneVNode(child);2129 }2130 else {2131 // strings and numbers2132 return createVNode(Text, null, String(child));2133 }2134}2135/**2136 * setupStatefulComponent2137 */2138function setupStatefulComponent(instance, isSSR) {2139 const Component = instance.type;2140 {2141 if (Component.name) {2142 validateComponentName(Component.name, instance.appContext.config);2143 }2144 if (Component.components) {2145 const names = Object.keys(Component.components);2146 for (let i = 0; i < names.length; i++) {2147 validateComponentName(names[i], instance.appContext.config);2148 }2149 }2150 if (Component.directives) {2151 const names = Object.keys(Component.directives);2152 for (let i = 0; i < names.length; i++) {2153 validateDirectiveName(names[i]);2154 }2155 }2156 }2157 // 0. create render proxy property access cache2158 instance.accessCache = {};2159 // 1. create public instance / render proxy2160 // also mark it raw so it's never observed2161 instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);2162 {2163 exposePropsOnRenderContext(instance);2164 }2165 // 2. call setup()2166 const { setup } = Component;2167 if (setup) {2168 const setupContext = (instance.setupContext =2169 setup.length > 1 ? createSetupContext(instance) : null);2170 currentInstance = instance;2171 pauseTracking();2172 const setupResult = callWithErrorHandling(setup, instance, 0 /* SETUP_FUNCTION */, [ shallowReadonly(instance.props) , setupContext]);2173 resetTracking();2174 currentInstance = null;2175 if (isPromise(setupResult)) {2176 if (isSSR) {2177 // return the promise so server-renderer can wait on it2178 return setupResult.then((resolvedResult) => {2179 handleSetupResult(instance, resolvedResult);2180 });2181 }2182 else {2183 // async setup returned Promise.2184 // bail here and wait for re-entry.2185 instance.asyncDep = setupResult;2186 }2187 }2188 else {2189 handleSetupResult(instance, setupResult);2190 }2191 }2192 else {2193 finishComponentSetup(instance);2194 }2195}2196function createSetupContext(instance) {2197 {2198 // We use getters in dev in case libs like test-utils overwrite instance2199 // properties (overwrites should not be done in prod)2200 return Object.freeze({2201 get attrs() {2202 return new Proxy(instance.attrs, attrHandlers);2203 },2204 get slots() {2205 return shallowReadonly(instance.slots);2206 },2207 get emit() {2208 return (event, ...args) => instance.emit(event, ...args);2209 }2210 });2211 }2212}2213function handleSetupResult(instance, setupResult, isSSR) {2214 if (isFunction(setupResult)) {2215 // setup returned an inline render function2216 instance.render = setupResult;2217 }2218 else if (isObject(setupResult)) {2219 if ( isVNode(setupResult)) {2220 warn(`setup() should not return VNodes directly - ` +2221 `return a render function instead.`);2222 }2223 // setup returned bindings.2224 // assuming a render function compiled from template is present.2225 {2226 instance.devtoolsRawSetupState = setupResult;2227 }2228 instance.setupState = proxyRefs(setupResult);2229 {2230 exposeSetupStateOnRenderContext(instance);2231 }2232 }2233 else if ( setupResult !== undefined) {2234 warn(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);2235 }2236 finishComponentSetup(instance);2237}2238function proxyRefs(objectWithRefs) {2239 return isReactive(objectWithRefs)2240 ? objectWithRefs2241 : new Proxy(objectWithRefs, shallowUnwrapHandlers);2242}2243function exposePropsOnRenderContext(instance) {2244 const { ctx, propsOptions: [propsOptions] } = instance;2245 if (propsOptions) {2246 Object.keys(propsOptions).forEach(key => {2247 Object.defineProperty(ctx, key, {2248 enumerable: true,2249 configurable: true,2250 get: () => instance.props[key],2251 set: NOOP2252 });2253 });2254 }2255}2256function finishComponentSetup(instance, isSSR) {2257 const Component = instance.type;...
setup.js
Source:setup.js
...160 // 1. create public instance / render proxy161 // also mark it raw so it's never observed162 instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);163 {164 exposePropsOnRenderContext(instance);165 }166 // 2. call setup()167 const { setup } = Component;168 if (setup) {169 const setupContext = (instance.setupContext =170 setup.length > 1 ? createSetupContext(instance) : null);171 currentInstance = instance;172 pauseTracking();173 const setupResult = callWithErrorHandling(setup, instance, 0 /* SETUP_FUNCTION */, [ shallowReadonly(instance.props) , setupContext]);174 resetTracking();175 currentInstance = null;176 if (isPromise(setupResult)) {177 if (isSSR) {178 // return the promise so server-renderer can wait on it...
Using AI Code Generation
1const playwright = require('playwright');2const { exposePropsOnRenderContext } = require('playwright/lib/server/browserContext');3(async () => {4 const browser = await playwright.chromium.launch();5 const context = await browser.newContext();6 exposePropsOnRenderContext(context, ['foo']);7 context.foo = 'bar';8 const page = await context.newPage();9 await page.evaluate(() => {10 });11 await browser.close();12})();
Using AI Code Generation
1const playwright = require('playwright');2const { exposePropsOnRenderContext } = require('playwright/lib/server/browserContext');3const browser = await playwright.chromium.launch();4const context = await browser.newContext();5exposePropsOnRenderContext(context, 'page');6const page = await context.newPage();7await page.screenshot({ path: 'example.png' });8await browser.close();9{10 "scripts": {11 },12 "dependencies": {13 }14}15const playwright = require('playwright');16const { exposePropsOnRenderContext } = require('playwright/lib/server/browserContext');17const browser = await playwright.chromium.launch();18const context = await browser.newContext();19exposePropsOnRenderContext(context, 'page');20const page = await context.newPage();21await page.screenshot({ path: 'example.png' });22await browser.close();23 at BrowserContext._wrapApiCall (/home/username/playwright-expose-props-on-render-context/node_modules/playwright/lib/server/browserContext.js:90:19)24 at BrowserContext.newPage (/home/username/playwright-expose-props-on-render-context/node_modules/playwright/lib/server/browserContext.js:300:26)25 at processTicksAndRejections (internal/process/task_queues.js:97:5)
Using AI Code Generation
1const { exposePropsOnRenderContext } = require('playwright/lib/server/dom.js');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await exposePropsOnRenderContext(page, ['window']);8 const title = await page.evaluate(() => window.document.title);9 console.log(title);10 await browser.close();11})();
Using AI Code Generation
1const playwright = require('playwright');2const { exposePropsOnRenderContext } = require('playwright/lib/internal/exports');3(async () => {4 const browser = await playwright.chromium.launch();5 const page = await browser.newPage();6 const context = await page.context();7 exposePropsOnRenderContext(context);8 await context.exposeBinding('myBinding', (source, ...args) => {9 return args[0] + ' ' + args[1];10 });11 const result = await page.evaluate(async () => {12 return await window.myBinding('hello', 'world');13 });14 console.log(result);15 await browser.close();16})();17const playwright = require('playwright');18const { exposePropsOnRenderContext } = require('playwright/lib/internal/exports');19describe('Playwright Test', () => {20 it('should work', async () => {21 const browser = await playwright.chromium.launch();22 const page = await browser.newPage();23 const context = await page.context();24 exposePropsOnRenderContext(context);25 await context.exposeBinding('myBinding', (source, ...args) => {26 return args[0] + ' ' + args[1];27 });28 const result = await page.evaluate(async () => {29 return await window.myBinding('hello', 'world');30 });31 console.log(result);32 await browser.close();33 });34});35const context = await page.context();36await context.exposeBinding('myBinding', (source, ...args) => {37 return args[0] + ' ' + args[1];38});39await context.exposeFunction('myFunction', (source, ...args) => {40 return args[0] + ' ' + args[1];41});42const result = await page.evaluate(async () => {43 return await window.myBinding('hello', 'world');44});45console.log(result);46const result2 = await page.evaluate(async () => {47 return await window.myFunction('hello', 'world');48});49console.log(result2);
Using AI Code Generation
1const playwright = require('playwright-core');2const { exposePropsOnRenderContext } = require('playwright-core/lib/server/supplements/recorder/recorderSupplement');3const { chromium } = require('playwright-core');4(async () => {5 const browser = await chromium.launch();6 const context = await browser.newContext();7 exposePropsOnRenderContext(context, ['page']);8 const page = await context.newPage();9 await page.screenshot({ path: `google.png` });10 await browser.close();11})();
Using AI Code Generation
1const { exposePropsOnRenderContext } = require('playwright/lib/server/browserContext');2const context = await browser.newContext();3exposePropsOnRenderContext(context, 'browserName', browser.name());4exposePropsOnRenderContext(context, 'deviceName', device.name());5exposePropsOnRenderContext(context, 'deviceScaleFactor', device.deviceScaleFactor());6exposePropsOnRenderContext(context, 'userAgent', device.userAgent());7exposePropsOnRenderContext(context, 'viewport', device.viewport());8exposePropsOnRenderContext(context, 'isMobile', device.isMobile());9exposePropsOnRenderContext(context, 'hasTouch', device.hasTouch());10exposePropsOnRenderContext(context, 'isLandscape', device.isLandscape());11const page = await context.newPage();12await page.screenshot({ path: 'example.png' });13const { exposePropsOnRenderContext } = require('playwright/lib/server/browserContext');14const context = await browser.newContext();15exposePropsOnRenderContext(context, 'browserName', browser.name());16exposePropsOnRenderContext(context, 'deviceName', device.name());17exposePropsOnRenderContext(context, 'deviceScaleFactor', device.deviceScaleFactor());18exposePropsOnRenderContext(context, 'userAgent', device.userAgent());19exposePropsOnRenderContext(context, 'viewport', device.viewport());20exposePropsOnRenderContext(context, 'isMobile', device.isMobile());21exposePropsOnRenderContext(context, 'hasTouch', device.hasTouch());22exposePropsOnRenderContext(context, 'isLandscape', device.isLandscape());23const page = await context.newPage();24await page.screenshot({ path: 'example.png' });25const { exposePropsOnRenderContext } = require('playwright/lib/server/browserContext');26const context = await browser.newContext();27exposePropsOnRenderContext(context, 'browserName', browser.name());28exposePropsOnRenderContext(context, 'deviceName', device.name());29exposePropsOnRenderContext(context, 'deviceScaleFactor', device.deviceScaleFactor());30exposePropsOnRenderContext(context, 'userAgent', device.userAgent());31exposePropsOnRenderContext(context, 'viewport
Using AI Code Generation
1const { exposePropsOnRenderContext } = require('playwright/lib/server/supplements/recorder/recorderSupplement');2exposePropsOnRenderContext({ test: "testValue" });3const { test } = require('./test');4const { test } = require('./test');5test('test', async ({ test }) => {6 expect(test).toBe('testValue');7});8const { test } = require('./test');9test('test', async ({ test }) =
Using AI Code Generation
1const { exposePropsOnRenderContext } = require('playwright/lib/server/browserContext');2const context = await browser.newContext();3exposePropsOnRenderContext(context, {4});5console.log(await page.evaluate(() => window.test));6exposePropsOnRenderContext(context: BrowserContext, props: Object)7const { exposePropsOnRenderContext } = require('playwright-internal-api');8const context = await browser.newContext();9exposePropsOnRenderContext(context, {10});11console.log(await page.evaluate(() => window.test));
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!