How to use mixSpecIntoComponent method in Playwright Internal

Best JavaScript code snippet using playwright-internal

reasonReactOptimizedCreateClass.js

Source:reasonReactOptimizedCreateClass.js Github

copy

Full Screen

...279 },280 mixins: function(Constructor, mixins) {281 if (mixins) {282 for (var i = 0; i < mixins.length; i++) {283 mixSpecIntoComponent(Constructor, mixins[i]);284 }285 }286 },287 childContextTypes: function(Constructor, childContextTypes) {288 // if (process.env.NODE_ENV !== 'production') {289 // validateTypeDef(Constructor, childContextTypes, 'childContext');290 // }291 Constructor.childContextTypes = _assign(292 {},293 Constructor.childContextTypes,294 childContextTypes295 );296 },297 contextTypes: function(Constructor, contextTypes) {298 // if (process.env.NODE_ENV !== 'production') {299 // validateTypeDef(Constructor, contextTypes, 'context');300 // }301 Constructor.contextTypes = _assign(302 {},303 Constructor.contextTypes,304 contextTypes305 );306 },307 /**308 * Special case getDefaultProps which should move into statics but requires309 * automatic merging.310 */311 getDefaultProps: function(Constructor, getDefaultProps) {312 if (Constructor.getDefaultProps) {313 Constructor.getDefaultProps = createMergedResultFunction(314 Constructor.getDefaultProps,315 getDefaultProps316 );317 } else {318 Constructor.getDefaultProps = getDefaultProps;319 }320 },321 propTypes: function(Constructor, propTypes) {322 // if (process.env.NODE_ENV !== 'production') {323 // validateTypeDef(Constructor, propTypes, 'prop');324 // }325 Constructor.propTypes = _assign({}, Constructor.propTypes, propTypes);326 },327 statics: function(Constructor, statics) {328 mixStaticSpecIntoComponent(Constructor, statics);329 },330 autobind: function() {}331 };332 function validateTypeDef(Constructor, typeDef, location) {333 for (var propName in typeDef) {334 // if (typeDef.hasOwnProperty(propName)) {335 // // use a warning instead of an _invariant so components336 // // don't show up in prod but only in __DEV__337 // // if (process.env.NODE_ENV !== 'production') {338 // // warning(339 // // typeof typeDef[propName] === 'function',340 // // '%s: %s type `%s` is invalid; it must be a function, usually from ' +341 // // 'React.PropTypes.',342 // // Constructor.displayName || 'ReactClass',343 // // ReactPropTypeLocationNames[location],344 // // propName345 // // );346 // // }347 // }348 }349 }350 function validateMethodOverride(isAlreadyDefined, name) {351 var specPolicy = ReactClassInterface.hasOwnProperty(name)352 ? ReactClassInterface[name]353 : null;354 // Disallow overriding of base class methods unless explicitly allowed.355 if (ReactClassMixin.hasOwnProperty(name)) {356 // _invariant(357 // specPolicy === 'OVERRIDE_BASE',358 // 'ReactClassInterface: You are attempting to override ' +359 // '`%s` from your class specification. Ensure that your method names ' +360 // 'do not overlap with React methods.',361 // name362 // );363 }364 // Disallow defining methods more than once unless explicitly allowed.365 if (isAlreadyDefined) {366 // _invariant(367 // specPolicy === 'DEFINE_MANY' || specPolicy === 'DEFINE_MANY_MERGED',368 // 'ReactClassInterface: You are attempting to define ' +369 // '`%s` on your component more than once. This conflict may be due ' +370 // 'to a mixin.',371 // name372 // );373 }374 }375 /**376 * Mixin helper which handles policy validation and reserved377 * specification keys when building React classes.378 */379 function mixSpecIntoComponent(Constructor, spec) {380 if (!spec) {381 // if (process.env.NODE_ENV !== 'production') {382 // var typeofSpec = typeof spec;383 // var isMixinValid = typeofSpec === 'object' && spec !== null;384 //385 // if (process.env.NODE_ENV !== 'production') {386 // warning(387 // isMixinValid,388 // "%s: You're attempting to include a mixin that is either null " +389 // 'or not an object. Check the mixins included by the component, ' +390 // 'as well as any mixins they include themselves. ' +391 // 'Expected object but got %s.',392 // Constructor.displayName || 'ReactClass',393 // spec === null ? null : typeofSpec394 // );395 // }396 // }397 return;398 }399 // _invariant(400 // typeof spec !== 'function',401 // "ReactClass: You're attempting to " +402 // 'use a component class or function as a mixin. Instead, just use a ' +403 // 'regular object.'404 // );405 // _invariant(406 // !isValidElement(spec),407 // "ReactClass: You're attempting to " +408 // 'use a component as a mixin. Instead, just use a regular object.'409 // );410 var proto = Constructor.prototype;411 var autoBindPairs = proto.__reactAutoBindPairs;412 // By handling mixins before any other properties, we ensure the same413 // chaining order is applied to methods with DEFINE_MANY policy, whether414 // mixins are listed before or after these methods in the spec.415 if (spec.hasOwnProperty(MIXINS_KEY)) {416 RESERVED_SPEC_KEYS.mixins(Constructor, spec.mixins);417 }418 for (var name in spec) {419 if (!spec.hasOwnProperty(name)) {420 continue;421 }422 if (name === MIXINS_KEY) {423 // We have already handled mixins in a special case above.424 continue;425 }426 var property = spec[name];427 var isAlreadyDefined = proto.hasOwnProperty(name);428 validateMethodOverride(isAlreadyDefined, name);429 if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {430 RESERVED_SPEC_KEYS[name](Constructor, property);431 } else {432 // Setup methods on prototype:433 // The following member methods should not be automatically bound:434 // 1. Expected ReactClass methods (in the "interface").435 // 2. Overridden methods (that were mixed in).436 var isReactClassMethod = ReactClassInterface.hasOwnProperty(name);437 var isFunction = typeof property === 'function';438 var shouldAutoBind =439 isFunction &&440 !isReactClassMethod &&441 !isAlreadyDefined &&442 spec.autobind !== false;443 if (shouldAutoBind) {444 autoBindPairs.push(name, property);445 proto[name] = property;446 } else {447 if (isAlreadyDefined) {448 var specPolicy = ReactClassInterface[name];449 // These cases should already be caught by validateMethodOverride.450 // _invariant(451 // isReactClassMethod &&452 // (specPolicy === 'DEFINE_MANY_MERGED' ||453 // specPolicy === 'DEFINE_MANY'),454 // 'ReactClass: Unexpected spec policy %s for key %s ' +455 // 'when mixing in component specs.',456 // specPolicy,457 // name458 // );459 // For methods which are defined more than once, call the existing460 // methods before calling the new property, merging if appropriate.461 if (specPolicy === 'DEFINE_MANY_MERGED') {462 proto[name] = createMergedResultFunction(proto[name], property);463 } else if (specPolicy === 'DEFINE_MANY') {464 proto[name] = createChainedFunction(proto[name], property);465 }466 } else {467 proto[name] = property;468 // if (process.env.NODE_ENV !== 'production') {469 // // Add verbose displayName to the function, which helps when looking470 // // at profiling tools.471 // if (typeof property === 'function' && spec.displayName) {472 // proto[name].displayName = spec.displayName + '_' + name;473 // }474 // }475 }476 }477 }478 }479 }480 function mixStaticSpecIntoComponent(Constructor, statics) {481 if (!statics) {482 return;483 }484 for (var name in statics) {485 var property = statics[name];486 if (!statics.hasOwnProperty(name)) {487 continue;488 }489 var isReserved = name in RESERVED_SPEC_KEYS;490 // _invariant(491 // !isReserved,492 // 'ReactClass: You are attempting to define a reserved ' +493 // 'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' +494 // 'as an instance property instead; it will still be accessible on the ' +495 // 'constructor.',496 // name497 // );498 var isInherited = name in Constructor;499 // _invariant(500 // !isInherited,501 // 'ReactClass: You are attempting to define ' +502 // '`%s` on your component more than once. This conflict may be ' +503 // 'due to a mixin.',504 // name505 // );506 Constructor[name] = property;507 }508 }509 /**510 * Merge two objects, but throw if both contain the same key.511 *512 * @param {object} one The first object, which is mutated.513 * @param {object} two The second object514 * @return {object} one after it has been mutated to contain everything in two.515 */516 function mergeIntoWithNoDuplicateKeys(one, two) {517 // _invariant(518 // one && two && typeof one === 'object' && typeof two === 'object',519 // 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.'520 // );521 for (var key in two) {522 if (two.hasOwnProperty(key)) {523 // _invariant(524 // one[key] === undefined,525 // 'mergeIntoWithNoDuplicateKeys(): ' +526 // 'Tried to merge two objects with the same key: `%s`. This conflict ' +527 // 'may be due to a mixin; in particular, this may be caused by two ' +528 // 'getInitialState() or getDefaultProps() methods returning objects ' +529 // 'with clashing keys.',530 // key531 // );532 one[key] = two[key];533 }534 }535 return one;536 }537 /**538 * Creates a function that invokes two functions and merges their return values.539 *540 * @param {function} one Function to invoke first.541 * @param {function} two Function to invoke second.542 * @return {function} Function that invokes the two argument functions.543 * @private544 */545 function createMergedResultFunction(one, two) {546 return function mergedResult() {547 var a = one.apply(this, arguments);548 var b = two.apply(this, arguments);549 if (a == null) {550 return b;551 } else if (b == null) {552 return a;553 }554 var c = {};555 mergeIntoWithNoDuplicateKeys(c, a);556 mergeIntoWithNoDuplicateKeys(c, b);557 return c;558 };559 }560 /**561 * Creates a function that invokes two functions and ignores their return vales.562 *563 * @param {function} one Function to invoke first.564 * @param {function} two Function to invoke second.565 * @return {function} Function that invokes the two argument functions.566 * @private567 */568 function createChainedFunction(one, two) {569 return function chainedFunction() {570 one.apply(this, arguments);571 two.apply(this, arguments);572 };573 }574 /**575 * Binds a method to the component.576 *577 * @param {object} component Component whose method is going to be bound.578 * @param {function} method Method to be bound.579 * @return {function} The bound method.580 */581 function bindAutoBindMethod(component, method) {582 var boundMethod = method.bind(component);583 // if (process.env.NODE_ENV !== 'production') {584 // boundMethod.__reactBoundContext = component;585 // boundMethod.__reactBoundMethod = method;586 // boundMethod.__reactBoundArguments = null;587 // var componentName = component.constructor.displayName;588 // var _bind = boundMethod.bind;589 // boundMethod.bind = function(newThis) {590 // for (591 // var _len = arguments.length,592 // args = Array(_len > 1 ? _len - 1 : 0),593 // _key = 1;594 // _key < _len;595 // _key++596 // ) {597 // args[_key - 1] = arguments[_key];598 // }599 //600 // // User is trying to bind() an autobound method; we effectively will601 // // ignore the value of "this" that the user is trying to use, so602 // // let's warn.603 // if (newThis !== component && newThis !== null) {604 // if (process.env.NODE_ENV !== 'production') {605 // warning(606 // false,607 // 'bind(): React component methods may only be bound to the ' +608 // 'component instance. See %s',609 // componentName610 // );611 // }612 // } else if (!args.length) {613 // if (process.env.NODE_ENV !== 'production') {614 // warning(615 // false,616 // 'bind(): You are binding a component method to the component. ' +617 // 'React does this for you automatically in a high-performance ' +618 // 'way, so you can safely remove this call. See %s',619 // componentName620 // );621 // }622 // return boundMethod;623 // }624 // var reboundMethod = _bind.apply(boundMethod, arguments);625 // reboundMethod.__reactBoundContext = component;626 // reboundMethod.__reactBoundMethod = method;627 // reboundMethod.__reactBoundArguments = args;628 // return reboundMethod;629 // };630 // }631 return boundMethod;632 }633 /**634 * Binds all auto-bound methods in a component.635 *636 * @param {object} component Component whose method is going to be bound.637 */638 function bindAutoBindMethods(component) {639 var pairs = component.__reactAutoBindPairs;640 for (var i = 0; i < pairs.length; i += 2) {641 var autoBindKey = pairs[i];642 var method = pairs[i + 1];643 component[autoBindKey] = bindAutoBindMethod(component, method);644 }645 }646 var IsMountedPreMixin = {647 componentDidMount: function() {648 this.__isMounted = true;649 }650 };651 var IsMountedPostMixin = {652 componentWillUnmount: function() {653 this.__isMounted = false;654 }655 };656 /**657 * Add more to the ReactClass base class. These are all legacy features and658 * therefore not already part of the modern ReactComponent.659 */660 var ReactClassMixin = {661 /**662 * TODO: This will be deprecated because state should always keep a consistent663 * type signature and the only use case for this, is to avoid that.664 */665 replaceState: function(newState, callback) {666 this.updater.enqueueReplaceState(this, newState, callback);667 },668 /**669 * Checks whether or not this composite component is mounted.670 * @return {boolean} True if mounted, false otherwise.671 * @protected672 * @final673 */674 isMounted: function() {675 // if (process.env.NODE_ENV !== 'production') {676 // warning(677 // this.__didWarnIsMounted,678 // '%s: isMounted is deprecated. Instead, make sure to clean up ' +679 // 'subscriptions and pending requests in componentWillUnmount to ' +680 // 'prevent memory leaks.',681 // (this.constructor && this.constructor.displayName) ||682 // this.name ||683 // 'Component'684 // );685 // this.__didWarnIsMounted = true;686 // }687 return !!this.__isMounted;688 }689 };690 var ReactClassComponent = function() {};691 _assign(692 ReactClassComponent.prototype,693 ReactComponent.prototype,694 ReactClassMixin695 );696 /**697 * Creates a composite component class given a class specification.698 * See https://facebook.github.io/react/docs/top-level-api.html#react.createclass699 *700 * @param {object} spec Class specification (which must define `render`).701 * @return {function} Component constructor function.702 * @public703 */704 function createClass(spec) {705 // To keep our warnings more understandable, we'll use a little hack here to706 // ensure that Constructor.name !== 'Constructor'. This makes sure we don't707 // unnecessarily identify a class without displayName as 'Constructor'.708 var Constructor = identity(function(props, context, updater) {709 // This constructor gets overridden by mocks. The argument is used710 // by mocks to assert on what gets mounted.711 // if (process.env.NODE_ENV !== 'production') {712 // warning(713 // this instanceof Constructor,714 // 'Something is calling a React component directly. Use a factory or ' +715 // 'JSX instead. See: https://fb.me/react-legacyfactory'716 // );717 // }718 // Wire up auto-binding719 if (this.__reactAutoBindPairs.length) {720 bindAutoBindMethods(this);721 }722 this.props = props;723 this.context = context;724 this.refs = emptyObject;725 this.updater = updater || ReactNoopUpdateQueue;726 this.state = null;727 // ReactClasses doesn't have constructors. Instead, they use the728 // getInitialState and componentWillMount methods for initialization.729 var initialState = this.getInitialState ? this.getInitialState() : null;730 // if (process.env.NODE_ENV !== 'production') {731 // // We allow auto-mocks to proceed as if they're returning null.732 // if (733 // initialState === undefined &&734 // this.getInitialState._isMockFunction735 // ) {736 // // This is probably bad practice. Consider warning here and737 // // deprecating this convenience.738 // initialState = null;739 // }740 // }741 // _invariant(742 // typeof initialState === 'object' && !Array.isArray(initialState),743 // '%s.getInitialState(): must return an object or null',744 // Constructor.displayName || 'ReactCompositeComponent'745 // );746 this.state = initialState;747 });748 Constructor.prototype = new ReactClassComponent();749 Constructor.prototype.constructor = Constructor;750 Constructor.prototype.__reactAutoBindPairs = [];751 injectedMixins.forEach(mixSpecIntoComponent.bind(null, Constructor));752 mixSpecIntoComponent(Constructor, IsMountedPreMixin);753 mixSpecIntoComponent(Constructor, spec);754 mixSpecIntoComponent(Constructor, IsMountedPostMixin);755 // Initialize the defaultProps property after all mixins have been merged.756 if (Constructor.getDefaultProps) {757 Constructor.defaultProps = Constructor.getDefaultProps();758 }759 // if (process.env.NODE_ENV !== 'production') {760 // // This is a tag to indicate that the use of these method names is ok,761 // // since it's used with createClass. If it's not, then it's likely a762 // // mistake so we'll warn you to use the static property, property763 // // initializer or constructor respectively.764 // if (Constructor.getDefaultProps) {765 // Constructor.getDefaultProps.isReactClassApproved = {};766 // }767 // if (Constructor.prototype.getInitialState) {768 // Constructor.prototype.getInitialState.isReactClassApproved = {};...

Full Screen

Full Screen

factory.js

Source:factory.js Github

copy

Full Screen

...48 },49 mixins: function(Constructor, mixins) {50 if (mixins) {51 for (var i = 0; i < mixins.length; i++) {52 mixSpecIntoComponent(Constructor, mixins[i]);53 }54 }55 },56 childContextTypes: function(Constructor, childContextTypes) {57 if (process.env.NODE_ENV !== 'production') {58 validateTypeDef(Constructor, childContextTypes, 'childContext');59 }60 Constructor.childContextTypes = _assign({}, Constructor.childContextTypes, childContextTypes);61 },62 contextTypes: function(Constructor, contextTypes) {63 if (process.env.NODE_ENV !== 'production') {64 validateTypeDef(Constructor, contextTypes, 'context');65 }66 Constructor.contextTypes = _assign({}, Constructor.contextTypes, contextTypes);67 },68 getDefaultProps: function(Constructor, getDefaultProps) {69 if (Constructor.getDefaultProps) {70 Constructor.getDefaultProps = createMergedResultFunction(Constructor.getDefaultProps, getDefaultProps);71 } else {72 Constructor.getDefaultProps = getDefaultProps;73 }74 },75 propTypes: function(Constructor, propTypes) {76 if (process.env.NODE_ENV !== 'production') {77 validateTypeDef(Constructor, propTypes, 'prop');78 }79 Constructor.propTypes = _assign({}, Constructor.propTypes, propTypes);80 },81 statics: function(Constructor, statics) {82 mixStaticSpecIntoComponent(Constructor, statics);83 },84 autobind: function() {}85 };86 function validateTypeDef(Constructor, typeDef, location) {87 for (var propName in typeDef) {88 if (typeDef.hasOwnProperty(propName)) {89 if (process.env.NODE_ENV !== 'production') {90 warning(typeof typeDef[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', Constructor.displayName || 'ReactClass', ReactPropTypeLocationNames[location], propName);91 }92 }93 }94 }95 function validateMethodOverride(isAlreadyDefined, name) {96 var specPolicy = ReactClassInterface.hasOwnProperty(name) ? ReactClassInterface[name] : null;97 if (ReactClassMixin.hasOwnProperty(name)) {98 _invariant(specPolicy === 'OVERRIDE_BASE', 'ReactClassInterface: You are attempting to override ' + '`%s` from your class specification. Ensure that your method names ' + 'do not overlap with React methods.', name);99 }100 if (isAlreadyDefined) {101 _invariant(specPolicy === 'DEFINE_MANY' || specPolicy === 'DEFINE_MANY_MERGED', 'ReactClassInterface: You are attempting to define ' + '`%s` on your component more than once. This conflict may be due ' + 'to a mixin.', name);102 }103 }104 function mixSpecIntoComponent(Constructor, spec) {105 if (!spec) {106 if (process.env.NODE_ENV !== 'production') {107 var typeofSpec = typeof spec;108 var isMixinValid = typeofSpec === 'object' && spec !== null;109 if (process.env.NODE_ENV !== 'production') {110 warning(isMixinValid, "%s: You're attempting to include a mixin that is either null " + 'or not an object. Check the mixins included by the component, ' + 'as well as any mixins they include themselves. ' + 'Expected object but got %s.', Constructor.displayName || 'ReactClass', spec === null ? null : typeofSpec);111 }112 }113 return;114 }115 _invariant(typeof spec !== 'function', "ReactClass: You're attempting to " + 'use a component class or function as a mixin. Instead, just use a ' + 'regular object.');116 _invariant(!isValidElement(spec), "ReactClass: You're attempting to " + 'use a component as a mixin. Instead, just use a regular object.');117 var proto = Constructor.prototype;118 var autoBindPairs = proto.__reactAutoBindPairs;119 if (spec.hasOwnProperty(MIXINS_KEY)) {120 RESERVED_SPEC_KEYS.mixins(Constructor, spec.mixins);121 }122 for (var name in spec) {123 if (!spec.hasOwnProperty(name)) {124 continue;125 }126 if (name === MIXINS_KEY) {127 continue;128 }129 var property = spec[name];130 var isAlreadyDefined = proto.hasOwnProperty(name);131 validateMethodOverride(isAlreadyDefined, name);132 if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {133 RESERVED_SPEC_KEYS[name](Constructor, property);134 } else {135 var isReactClassMethod = ReactClassInterface.hasOwnProperty(name);136 var isFunction = typeof property === 'function';137 var shouldAutoBind = isFunction && !isReactClassMethod && !isAlreadyDefined && spec.autobind !== false;138 if (shouldAutoBind) {139 autoBindPairs.push(name, property);140 proto[name] = property;141 } else {142 if (isAlreadyDefined) {143 var specPolicy = ReactClassInterface[name];144 _invariant(isReactClassMethod && (specPolicy === 'DEFINE_MANY_MERGED' || specPolicy === 'DEFINE_MANY'), 'ReactClass: Unexpected spec policy %s for key %s ' + 'when mixing in component specs.', specPolicy, name);145 if (specPolicy === 'DEFINE_MANY_MERGED') {146 proto[name] = createMergedResultFunction(proto[name], property);147 } else if (specPolicy === 'DEFINE_MANY') {148 proto[name] = createChainedFunction(proto[name], property);149 }150 } else {151 proto[name] = property;152 if (process.env.NODE_ENV !== 'production') {153 if (typeof property === 'function' && spec.displayName) {154 proto[name].displayName = spec.displayName + '_' + name;155 }156 }157 }158 }159 }160 }161 }162 function mixStaticSpecIntoComponent(Constructor, statics) {163 if (!statics) {164 return;165 }166 for (var name in statics) {167 var property = statics[name];168 if (!statics.hasOwnProperty(name)) {169 continue;170 }171 var isReserved = name in RESERVED_SPEC_KEYS;172 _invariant(!isReserved, 'ReactClass: You are attempting to define a reserved ' + 'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' + 'as an instance property instead; it will still be accessible on the ' + 'constructor.', name);173 var isInherited = name in Constructor;174 _invariant(!isInherited, 'ReactClass: You are attempting to define ' + '`%s` on your component more than once. This conflict may be ' + 'due to a mixin.', name);175 Constructor[name] = property;176 }177 }178 function mergeIntoWithNoDuplicateKeys(one, two) {179 _invariant(one && two && typeof one === 'object' && typeof two === 'object', 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.');180 for (var key in two) {181 if (two.hasOwnProperty(key)) {182 _invariant(one[key] === undefined, 'mergeIntoWithNoDuplicateKeys(): ' + 'Tried to merge two objects with the same key: `%s`. This conflict ' + 'may be due to a mixin; in particular, this may be caused by two ' + 'getInitialState() or getDefaultProps() methods returning objects ' + 'with clashing keys.', key);183 one[key] = two[key];184 }185 }186 return one;187 }188 function createMergedResultFunction(one, two) {189 return function mergedResult() {190 var a = one.apply(this, arguments);191 var b = two.apply(this, arguments);192 if (a == null) {193 return b;194 } else if (b == null) {195 return a;196 }197 var c = {};198 mergeIntoWithNoDuplicateKeys(c, a);199 mergeIntoWithNoDuplicateKeys(c, b);200 return c;201 };202 }203 function createChainedFunction(one, two) {204 return function chainedFunction() {205 one.apply(this, arguments);206 two.apply(this, arguments);207 };208 }209 function bindAutoBindMethod(component, method) {210 var boundMethod = method.bind(component);211 if (process.env.NODE_ENV !== 'production') {212 boundMethod.__reactBoundContext = component;213 boundMethod.__reactBoundMethod = method;214 boundMethod.__reactBoundArguments = null;215 var componentName = component.constructor.displayName;216 var _bind = boundMethod.bind;217 boundMethod.bind = function(newThis) {218 for (var _len = arguments.length,219 args = Array(_len > 1 ? _len - 1 : 0),220 _key = 1; _key < _len; _key++) {221 args[_key - 1] = arguments[_key];222 }223 if (newThis !== component && newThis !== null) {224 if (process.env.NODE_ENV !== 'production') {225 warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance. See %s', componentName);226 }227 } else if (!args.length) {228 if (process.env.NODE_ENV !== 'production') {229 warning(false, 'bind(): You are binding a component method to the component. ' + 'React does this for you automatically in a high-performance ' + 'way, so you can safely remove this call. See %s', componentName);230 }231 return boundMethod;232 }233 var reboundMethod = _bind.apply(boundMethod, arguments);234 reboundMethod.__reactBoundContext = component;235 reboundMethod.__reactBoundMethod = method;236 reboundMethod.__reactBoundArguments = args;237 return reboundMethod;238 };239 }240 return boundMethod;241 }242 function bindAutoBindMethods(component) {243 var pairs = component.__reactAutoBindPairs;244 for (var i = 0; i < pairs.length; i += 2) {245 var autoBindKey = pairs[i];246 var method = pairs[i + 1];247 component[autoBindKey] = bindAutoBindMethod(component, method);248 }249 }250 var IsMountedPreMixin = {componentDidMount: function() {251 this.__isMounted = true;252 }};253 var IsMountedPostMixin = {componentWillUnmount: function() {254 this.__isMounted = false;255 }};256 var ReactClassMixin = {257 replaceState: function(newState, callback) {258 this.updater.enqueueReplaceState(this, newState, callback);259 },260 isMounted: function() {261 if (process.env.NODE_ENV !== 'production') {262 warning(this.__didWarnIsMounted, '%s: isMounted is deprecated. Instead, make sure to clean up ' + 'subscriptions and pending requests in componentWillUnmount to ' + 'prevent memory leaks.', (this.constructor && this.constructor.displayName) || this.name || 'Component');263 this.__didWarnIsMounted = true;264 }265 return !!this.__isMounted;266 }267 };268 var ReactClassComponent = function() {};269 _assign(ReactClassComponent.prototype, ReactComponent.prototype, ReactClassMixin);270 function createClass(spec) {271 var Constructor = identity(function(props, context, updater) {272 if (process.env.NODE_ENV !== 'production') {273 warning(this instanceof Constructor, 'Something is calling a React component directly. Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory');274 }275 if (this.__reactAutoBindPairs.length) {276 bindAutoBindMethods(this);277 }278 this.props = props;279 this.context = context;280 this.refs = emptyObject;281 this.updater = updater || ReactNoopUpdateQueue;282 this.state = null;283 var initialState = this.getInitialState ? this.getInitialState() : null;284 if (process.env.NODE_ENV !== 'production') {285 if (initialState === undefined && this.getInitialState._isMockFunction) {286 initialState = null;287 }288 }289 _invariant(typeof initialState === 'object' && !Array.isArray(initialState), '%s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent');290 this.state = initialState;291 });292 Constructor.prototype = new ReactClassComponent();293 Constructor.prototype.constructor = Constructor;294 Constructor.prototype.__reactAutoBindPairs = [];295 injectedMixins.forEach(mixSpecIntoComponent.bind(null, Constructor));296 mixSpecIntoComponent(Constructor, IsMountedPreMixin);297 mixSpecIntoComponent(Constructor, spec);298 mixSpecIntoComponent(Constructor, IsMountedPostMixin);299 if (Constructor.getDefaultProps) {300 Constructor.defaultProps = Constructor.getDefaultProps();301 }302 if (process.env.NODE_ENV !== 'production') {303 if (Constructor.getDefaultProps) {304 Constructor.getDefaultProps.isReactClassApproved = {};305 }306 if (Constructor.prototype.getInitialState) {307 Constructor.prototype.getInitialState.isReactClassApproved = {};308 }309 }310 _invariant(Constructor.prototype.render, 'createClass(...): Class specification must implement a `render` method.');311 if (process.env.NODE_ENV !== 'production') {312 warning(!Constructor.prototype.componentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', spec.displayName || 'A component');...

Full Screen

Full Screen

7436cab36721dae157a45430e7adab6c62de79factory.js

Source:7436cab36721dae157a45430e7adab6c62de79factory.js Github

copy

Full Screen

...46 },47 mixins: function mixins(Constructor, _mixins) {48 if (_mixins) {49 for (var i = 0; i < _mixins.length; i++) {50 mixSpecIntoComponent(Constructor, _mixins[i]);51 }52 }53 },54 childContextTypes: function childContextTypes(Constructor, _childContextTypes) {55 if (process.env.NODE_ENV !== 'production') {56 validateTypeDef(Constructor, _childContextTypes, 'childContext');57 }58 Constructor.childContextTypes = _assign({}, Constructor.childContextTypes, _childContextTypes);59 },60 contextTypes: function contextTypes(Constructor, _contextTypes) {61 if (process.env.NODE_ENV !== 'production') {62 validateTypeDef(Constructor, _contextTypes, 'context');63 }64 Constructor.contextTypes = _assign({}, Constructor.contextTypes, _contextTypes);65 },66 getDefaultProps: function getDefaultProps(Constructor, _getDefaultProps) {67 if (Constructor.getDefaultProps) {68 Constructor.getDefaultProps = createMergedResultFunction(Constructor.getDefaultProps, _getDefaultProps);69 } else {70 Constructor.getDefaultProps = _getDefaultProps;71 }72 },73 propTypes: function propTypes(Constructor, _propTypes) {74 if (process.env.NODE_ENV !== 'production') {75 validateTypeDef(Constructor, _propTypes, 'prop');76 }77 Constructor.propTypes = _assign({}, Constructor.propTypes, _propTypes);78 },79 statics: function statics(Constructor, _statics) {80 mixStaticSpecIntoComponent(Constructor, _statics);81 },82 autobind: function autobind() {}83 };84 function validateTypeDef(Constructor, typeDef, location) {85 for (var propName in typeDef) {86 if (typeDef.hasOwnProperty(propName)) {87 if (process.env.NODE_ENV !== 'production') {88 warning(typeof typeDef[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', Constructor.displayName || 'ReactClass', ReactPropTypeLocationNames[location], propName);89 }90 }91 }92 }93 function validateMethodOverride(isAlreadyDefined, name) {94 var specPolicy = ReactClassInterface.hasOwnProperty(name) ? ReactClassInterface[name] : null;95 if (ReactClassMixin.hasOwnProperty(name)) {96 _invariant(specPolicy === 'OVERRIDE_BASE', 'ReactClassInterface: You are attempting to override ' + '`%s` from your class specification. Ensure that your method names ' + 'do not overlap with React methods.', name);97 }98 if (isAlreadyDefined) {99 _invariant(specPolicy === 'DEFINE_MANY' || specPolicy === 'DEFINE_MANY_MERGED', 'ReactClassInterface: You are attempting to define ' + '`%s` on your component more than once. This conflict may be due ' + 'to a mixin.', name);100 }101 }102 function mixSpecIntoComponent(Constructor, spec) {103 if (!spec) {104 if (process.env.NODE_ENV !== 'production') {105 var typeofSpec = typeof spec;106 var isMixinValid = typeofSpec === 'object' && spec !== null;107 if (process.env.NODE_ENV !== 'production') {108 warning(isMixinValid, "%s: You're attempting to include a mixin that is either null " + 'or not an object. Check the mixins included by the component, ' + 'as well as any mixins they include themselves. ' + 'Expected object but got %s.', Constructor.displayName || 'ReactClass', spec === null ? null : typeofSpec);109 }110 }111 return;112 }113 _invariant(typeof spec !== 'function', "ReactClass: You're attempting to " + 'use a component class or function as a mixin. Instead, just use a ' + 'regular object.');114 _invariant(!isValidElement(spec), "ReactClass: You're attempting to " + 'use a component as a mixin. Instead, just use a regular object.');115 var proto = Constructor.prototype;116 var autoBindPairs = proto.__reactAutoBindPairs;117 if (spec.hasOwnProperty(MIXINS_KEY)) {118 RESERVED_SPEC_KEYS.mixins(Constructor, spec.mixins);119 }120 for (var name in spec) {121 if (!spec.hasOwnProperty(name)) {122 continue;123 }124 if (name === MIXINS_KEY) {125 continue;126 }127 var property = spec[name];128 var isAlreadyDefined = proto.hasOwnProperty(name);129 validateMethodOverride(isAlreadyDefined, name);130 if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {131 RESERVED_SPEC_KEYS[name](Constructor, property);132 } else {133 var isReactClassMethod = ReactClassInterface.hasOwnProperty(name);134 var isFunction = typeof property === 'function';135 var shouldAutoBind = isFunction && !isReactClassMethod && !isAlreadyDefined && spec.autobind !== false;136 if (shouldAutoBind) {137 autoBindPairs.push(name, property);138 proto[name] = property;139 } else {140 if (isAlreadyDefined) {141 var specPolicy = ReactClassInterface[name];142 _invariant(isReactClassMethod && (specPolicy === 'DEFINE_MANY_MERGED' || specPolicy === 'DEFINE_MANY'), 'ReactClass: Unexpected spec policy %s for key %s ' + 'when mixing in component specs.', specPolicy, name);143 if (specPolicy === 'DEFINE_MANY_MERGED') {144 proto[name] = createMergedResultFunction(proto[name], property);145 } else if (specPolicy === 'DEFINE_MANY') {146 proto[name] = createChainedFunction(proto[name], property);147 }148 } else {149 proto[name] = property;150 if (process.env.NODE_ENV !== 'production') {151 if (typeof property === 'function' && spec.displayName) {152 proto[name].displayName = spec.displayName + '_' + name;153 }154 }155 }156 }157 }158 }159 }160 function mixStaticSpecIntoComponent(Constructor, statics) {161 if (!statics) {162 return;163 }164 for (var name in statics) {165 var property = statics[name];166 if (!statics.hasOwnProperty(name)) {167 continue;168 }169 var isReserved = name in RESERVED_SPEC_KEYS;170 _invariant(!isReserved, 'ReactClass: You are attempting to define a reserved ' + 'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' + 'as an instance property instead; it will still be accessible on the ' + 'constructor.', name);171 var isInherited = name in Constructor;172 _invariant(!isInherited, 'ReactClass: You are attempting to define ' + '`%s` on your component more than once. This conflict may be ' + 'due to a mixin.', name);173 Constructor[name] = property;174 }175 }176 function mergeIntoWithNoDuplicateKeys(one, two) {177 _invariant(one && two && typeof one === 'object' && typeof two === 'object', 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.');178 for (var key in two) {179 if (two.hasOwnProperty(key)) {180 _invariant(one[key] === undefined, 'mergeIntoWithNoDuplicateKeys(): ' + 'Tried to merge two objects with the same key: `%s`. This conflict ' + 'may be due to a mixin; in particular, this may be caused by two ' + 'getInitialState() or getDefaultProps() methods returning objects ' + 'with clashing keys.', key);181 one[key] = two[key];182 }183 }184 return one;185 }186 function createMergedResultFunction(one, two) {187 return function mergedResult() {188 var a = one.apply(this, arguments);189 var b = two.apply(this, arguments);190 if (a == null) {191 return b;192 } else if (b == null) {193 return a;194 }195 var c = {};196 mergeIntoWithNoDuplicateKeys(c, a);197 mergeIntoWithNoDuplicateKeys(c, b);198 return c;199 };200 }201 function createChainedFunction(one, two) {202 return function chainedFunction() {203 one.apply(this, arguments);204 two.apply(this, arguments);205 };206 }207 function bindAutoBindMethod(component, method) {208 var boundMethod = method.bind(component);209 if (process.env.NODE_ENV !== 'production') {210 boundMethod.__reactBoundContext = component;211 boundMethod.__reactBoundMethod = method;212 boundMethod.__reactBoundArguments = null;213 var componentName = component.constructor.displayName;214 var _bind = boundMethod.bind;215 boundMethod.bind = function (newThis) {216 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {217 args[_key - 1] = arguments[_key];218 }219 if (newThis !== component && newThis !== null) {220 if (process.env.NODE_ENV !== 'production') {221 warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance. See %s', componentName);222 }223 } else if (!args.length) {224 if (process.env.NODE_ENV !== 'production') {225 warning(false, 'bind(): You are binding a component method to the component. ' + 'React does this for you automatically in a high-performance ' + 'way, so you can safely remove this call. See %s', componentName);226 }227 return boundMethod;228 }229 var reboundMethod = _bind.apply(boundMethod, arguments);230 reboundMethod.__reactBoundContext = component;231 reboundMethod.__reactBoundMethod = method;232 reboundMethod.__reactBoundArguments = args;233 return reboundMethod;234 };235 }236 return boundMethod;237 }238 function bindAutoBindMethods(component) {239 var pairs = component.__reactAutoBindPairs;240 for (var i = 0; i < pairs.length; i += 2) {241 var autoBindKey = pairs[i];242 var method = pairs[i + 1];243 component[autoBindKey] = bindAutoBindMethod(component, method);244 }245 }246 var IsMountedPreMixin = {247 componentDidMount: function componentDidMount() {248 this.__isMounted = true;249 }250 };251 var IsMountedPostMixin = {252 componentWillUnmount: function componentWillUnmount() {253 this.__isMounted = false;254 }255 };256 var ReactClassMixin = {257 replaceState: function replaceState(newState, callback) {258 this.updater.enqueueReplaceState(this, newState, callback);259 },260 isMounted: function isMounted() {261 if (process.env.NODE_ENV !== 'production') {262 warning(this.__didWarnIsMounted, '%s: isMounted is deprecated. Instead, make sure to clean up ' + 'subscriptions and pending requests in componentWillUnmount to ' + 'prevent memory leaks.', this.constructor && this.constructor.displayName || this.name || 'Component');263 this.__didWarnIsMounted = true;264 }265 return !!this.__isMounted;266 }267 };268 var ReactClassComponent = function ReactClassComponent() {};269 _assign(ReactClassComponent.prototype, ReactComponent.prototype, ReactClassMixin);270 function createClass(spec) {271 var Constructor = identity(function (props, context, updater) {272 if (process.env.NODE_ENV !== 'production') {273 warning(this instanceof Constructor, 'Something is calling a React component directly. Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory');274 }275 if (this.__reactAutoBindPairs.length) {276 bindAutoBindMethods(this);277 }278 this.props = props;279 this.context = context;280 this.refs = emptyObject;281 this.updater = updater || ReactNoopUpdateQueue;282 this.state = null;283 var initialState = this.getInitialState ? this.getInitialState() : null;284 if (process.env.NODE_ENV !== 'production') {285 if (initialState === undefined && this.getInitialState._isMockFunction) {286 initialState = null;287 }288 }289 _invariant(typeof initialState === 'object' && !Array.isArray(initialState), '%s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent');290 this.state = initialState;291 });292 Constructor.prototype = new ReactClassComponent();293 Constructor.prototype.constructor = Constructor;294 Constructor.prototype.__reactAutoBindPairs = [];295 injectedMixins.forEach(mixSpecIntoComponent.bind(null, Constructor));296 mixSpecIntoComponent(Constructor, IsMountedPreMixin);297 mixSpecIntoComponent(Constructor, spec);298 mixSpecIntoComponent(Constructor, IsMountedPostMixin);299 if (Constructor.getDefaultProps) {300 Constructor.defaultProps = Constructor.getDefaultProps();301 }302 if (process.env.NODE_ENV !== 'production') {303 if (Constructor.getDefaultProps) {304 Constructor.getDefaultProps.isReactClassApproved = {};305 }306 if (Constructor.prototype.getInitialState) {307 Constructor.prototype.getInitialState.isReactClassApproved = {};308 }309 }310 _invariant(Constructor.prototype.render, 'createClass(...): Class specification must implement a `render` method.');311 if (process.env.NODE_ENV !== 'production') {312 warning(!Constructor.prototype.componentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', spec.displayName || 'A component');...

Full Screen

Full Screen

b572cfReactClass.js

Source:b572cfReactClass.js Github

copy

Full Screen

...38 },39 mixins: function mixins(Constructor, _mixins) {40 if (_mixins) {41 for (var i = 0; i < _mixins.length; i++) {42 mixSpecIntoComponent(Constructor, _mixins[i]);43 }44 }45 },46 childContextTypes: function childContextTypes(Constructor, _childContextTypes) {47 if (process.env.NODE_ENV !== 'production') {48 validateTypeDef(Constructor, _childContextTypes, 'childContext');49 }50 Constructor.childContextTypes = _assign({}, Constructor.childContextTypes, _childContextTypes);51 },52 contextTypes: function contextTypes(Constructor, _contextTypes) {53 if (process.env.NODE_ENV !== 'production') {54 validateTypeDef(Constructor, _contextTypes, 'context');55 }56 Constructor.contextTypes = _assign({}, Constructor.contextTypes, _contextTypes);57 },58 getDefaultProps: function getDefaultProps(Constructor, _getDefaultProps) {59 if (Constructor.getDefaultProps) {60 Constructor.getDefaultProps = createMergedResultFunction(Constructor.getDefaultProps, _getDefaultProps);61 } else {62 Constructor.getDefaultProps = _getDefaultProps;63 }64 },65 propTypes: function propTypes(Constructor, _propTypes) {66 if (process.env.NODE_ENV !== 'production') {67 validateTypeDef(Constructor, _propTypes, 'prop');68 }69 Constructor.propTypes = _assign({}, Constructor.propTypes, _propTypes);70 },71 statics: function statics(Constructor, _statics) {72 mixStaticSpecIntoComponent(Constructor, _statics);73 },74 autobind: function autobind() {} };75function validateTypeDef(Constructor, typeDef, location) {76 for (var propName in typeDef) {77 if (typeDef.hasOwnProperty(propName)) {78 process.env.NODE_ENV !== 'production' ? warning(typeof typeDef[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', Constructor.displayName || 'ReactClass', ReactPropTypeLocationNames[location], propName) : void 0;79 }80 }81}82function validateMethodOverride(isAlreadyDefined, name) {83 var specPolicy = ReactClassInterface.hasOwnProperty(name) ? ReactClassInterface[name] : null;84 if (ReactClassMixin.hasOwnProperty(name)) {85 !(specPolicy === 'OVERRIDE_BASE') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClassInterface: You are attempting to override `%s` from your class specification. Ensure that your method names do not overlap with React methods.', name) : _prodInvariant('73', name) : void 0;86 }87 if (isAlreadyDefined) {88 !(specPolicy === 'DEFINE_MANY' || specPolicy === 'DEFINE_MANY_MERGED') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClassInterface: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.', name) : _prodInvariant('74', name) : void 0;89 }90}91function mixSpecIntoComponent(Constructor, spec) {92 if (!spec) {93 if (process.env.NODE_ENV !== 'production') {94 var typeofSpec = typeof spec;95 var isMixinValid = typeofSpec === 'object' && spec !== null;96 process.env.NODE_ENV !== 'production' ? warning(isMixinValid, '%s: You\'re attempting to include a mixin that is either null ' + 'or not an object. Check the mixins included by the component, ' + 'as well as any mixins they include themselves. ' + 'Expected object but got %s.', Constructor.displayName || 'ReactClass', spec === null ? null : typeofSpec) : void 0;97 }98 return;99 }100 !(typeof spec !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to use a component class or function as a mixin. Instead, just use a regular object.') : _prodInvariant('75') : void 0;101 !!ReactElement.isValidElement(spec) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to use a component as a mixin. Instead, just use a regular object.') : _prodInvariant('76') : void 0;102 var proto = Constructor.prototype;103 var autoBindPairs = proto.__reactAutoBindPairs;104 if (spec.hasOwnProperty(MIXINS_KEY)) {105 RESERVED_SPEC_KEYS.mixins(Constructor, spec.mixins);106 }107 for (var name in spec) {108 if (!spec.hasOwnProperty(name)) {109 continue;110 }111 if (name === MIXINS_KEY) {112 continue;113 }114 var property = spec[name];115 var isAlreadyDefined = proto.hasOwnProperty(name);116 validateMethodOverride(isAlreadyDefined, name);117 if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {118 RESERVED_SPEC_KEYS[name](Constructor, property);119 } else {120 var isReactClassMethod = ReactClassInterface.hasOwnProperty(name);121 var isFunction = typeof property === 'function';122 var shouldAutoBind = isFunction && !isReactClassMethod && !isAlreadyDefined && spec.autobind !== false;123 if (shouldAutoBind) {124 autoBindPairs.push(name, property);125 proto[name] = property;126 } else {127 if (isAlreadyDefined) {128 var specPolicy = ReactClassInterface[name];129 !(isReactClassMethod && (specPolicy === 'DEFINE_MANY_MERGED' || specPolicy === 'DEFINE_MANY')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: Unexpected spec policy %s for key %s when mixing in component specs.', specPolicy, name) : _prodInvariant('77', specPolicy, name) : void 0;130 if (specPolicy === 'DEFINE_MANY_MERGED') {131 proto[name] = createMergedResultFunction(proto[name], property);132 } else if (specPolicy === 'DEFINE_MANY') {133 proto[name] = createChainedFunction(proto[name], property);134 }135 } else {136 proto[name] = property;137 if (process.env.NODE_ENV !== 'production') {138 if (typeof property === 'function' && spec.displayName) {139 proto[name].displayName = spec.displayName + '_' + name;140 }141 }142 }143 }144 }145 }146}147function mixStaticSpecIntoComponent(Constructor, statics) {148 if (!statics) {149 return;150 }151 for (var name in statics) {152 var property = statics[name];153 if (!statics.hasOwnProperty(name)) {154 continue;155 }156 var isReserved = name in RESERVED_SPEC_KEYS;157 !!isReserved ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You are attempting to define a reserved property, `%s`, that shouldn\'t be on the "statics" key. Define it as an instance property instead; it will still be accessible on the constructor.', name) : _prodInvariant('78', name) : void 0;158 var isInherited = name in Constructor;159 !!isInherited ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.', name) : _prodInvariant('79', name) : void 0;160 Constructor[name] = property;161 }162}163function mergeIntoWithNoDuplicateKeys(one, two) {164 !(one && two && typeof one === 'object' && typeof two === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.') : _prodInvariant('80') : void 0;165 for (var key in two) {166 if (two.hasOwnProperty(key)) {167 !(one[key] === undefined) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): Tried to merge two objects with the same key: `%s`. This conflict may be due to a mixin; in particular, this may be caused by two getInitialState() or getDefaultProps() methods returning objects with clashing keys.', key) : _prodInvariant('81', key) : void 0;168 one[key] = two[key];169 }170 }171 return one;172}173function createMergedResultFunction(one, two) {174 return function mergedResult() {175 var a = one.apply(this, arguments);176 var b = two.apply(this, arguments);177 if (a == null) {178 return b;179 } else if (b == null) {180 return a;181 }182 var c = {};183 mergeIntoWithNoDuplicateKeys(c, a);184 mergeIntoWithNoDuplicateKeys(c, b);185 return c;186 };187}188function createChainedFunction(one, two) {189 return function chainedFunction() {190 one.apply(this, arguments);191 two.apply(this, arguments);192 };193}194function bindAutoBindMethod(component, method) {195 var boundMethod = method.bind(component);196 if (process.env.NODE_ENV !== 'production') {197 boundMethod.__reactBoundContext = component;198 boundMethod.__reactBoundMethod = method;199 boundMethod.__reactBoundArguments = null;200 var componentName = component.constructor.displayName;201 var _bind = boundMethod.bind;202 boundMethod.bind = function (newThis) {203 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {204 args[_key - 1] = arguments[_key];205 }206 if (newThis !== component && newThis !== null) {207 process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance. See %s', componentName) : void 0;208 } else if (!args.length) {209 process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): You are binding a component method to the component. ' + 'React does this for you automatically in a high-performance ' + 'way, so you can safely remove this call. See %s', componentName) : void 0;210 return boundMethod;211 }212 var reboundMethod = _bind.apply(boundMethod, arguments);213 reboundMethod.__reactBoundContext = component;214 reboundMethod.__reactBoundMethod = method;215 reboundMethod.__reactBoundArguments = args;216 return reboundMethod;217 };218 }219 return boundMethod;220}221function bindAutoBindMethods(component) {222 var pairs = component.__reactAutoBindPairs;223 for (var i = 0; i < pairs.length; i += 2) {224 var autoBindKey = pairs[i];225 var method = pairs[i + 1];226 component[autoBindKey] = bindAutoBindMethod(component, method);227 }228}229var ReactClassMixin = {230 replaceState: function replaceState(newState, callback) {231 this.updater.enqueueReplaceState(this, newState);232 if (callback) {233 this.updater.enqueueCallback(this, callback, 'replaceState');234 }235 },236 isMounted: function isMounted() {237 return this.updater.isMounted(this);238 }239};240var ReactClassComponent = function ReactClassComponent() {};241_assign(ReactClassComponent.prototype, ReactComponent.prototype, ReactClassMixin);242var ReactClass = {243 createClass: function createClass(spec) {244 var Constructor = identity(function (props, context, updater) {245 if (process.env.NODE_ENV !== 'production') {246 process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly. Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : void 0;247 }248 if (this.__reactAutoBindPairs.length) {249 bindAutoBindMethods(this);250 }251 this.props = props;252 this.context = context;253 this.refs = emptyObject;254 this.updater = updater || ReactNoopUpdateQueue;255 this.state = null;256 var initialState = this.getInitialState ? this.getInitialState() : null;257 if (process.env.NODE_ENV !== 'production') {258 if (initialState === undefined && this.getInitialState._isMockFunction) {259 initialState = null;260 }261 }262 !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : _prodInvariant('82', Constructor.displayName || 'ReactCompositeComponent') : void 0;263 this.state = initialState;264 });265 Constructor.prototype = new ReactClassComponent();266 Constructor.prototype.constructor = Constructor;267 Constructor.prototype.__reactAutoBindPairs = [];268 injectedMixins.forEach(mixSpecIntoComponent.bind(null, Constructor));269 mixSpecIntoComponent(Constructor, spec);270 if (Constructor.getDefaultProps) {271 Constructor.defaultProps = Constructor.getDefaultProps();272 }273 if (process.env.NODE_ENV !== 'production') {274 if (Constructor.getDefaultProps) {275 Constructor.getDefaultProps.isReactClassApproved = {};276 }277 if (Constructor.prototype.getInitialState) {278 Constructor.prototype.getInitialState.isReactClassApproved = {};279 }280 }281 !Constructor.prototype.render ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createClass(...): Class specification must implement a `render` method.') : _prodInvariant('83') : void 0;282 if (process.env.NODE_ENV !== 'production') {283 process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', spec.displayName || 'A component') : void 0;...

Full Screen

Full Screen

react-internal.js

Source:react-internal.js Github

copy

Full Screen

...76 },77 mixins: function(Constructor, mixins) {78 if (mixins) {79 for (var i = 0; i < mixins.length; i++) {80 mixSpecIntoComponent(Constructor, mixins[i]);81 }82 }83 },84 childContextTypes: function(Constructor, childContextTypes) {85 validateTypeDef(86 Constructor,87 childContextTypes,88 ReactPropTypeLocations.childContext89 );90 Constructor.childContextTypes = merge(91 Constructor.childContextTypes,92 childContextTypes93 );94 },95 contextTypes: function(Constructor, contextTypes) {96 validateTypeDef(97 Constructor,98 contextTypes,99 ReactPropTypeLocations.context100 );101 Constructor.contextTypes = merge(Constructor.contextTypes, contextTypes);102 },103 propTypes: function(Constructor, propTypes) {104 validateTypeDef(105 Constructor,106 propTypes,107 ReactPropTypeLocations.prop108 );109 Constructor.propTypes = merge(Constructor.propTypes, propTypes);110 }, 111 statics: function(Constructor, statics) {112 mixStaticSpecIntoComponent(Constructor, statics);113 }114};115function validateMethodOverride(proto, name) {116 var specPolicy = ReactCompositeComponentInterface[name];117 // Disallow overriding of base class methods unless explicitly allowed.118 if (ReactCompositeComponentMixin.hasOwnProperty(name)) {119 invariant(120 specPolicy === SpecPolicy.OVERRIDE_BASE,121 'ReactCompositeComponentInterface: You are attempting to override ' +122 '`%s` from your class specification. Ensure that your method names ' +123 'do not overlap with React methods.',124 name125 );126 }127 // Disallow defining methods more than once unless explicitly allowed.128 if (proto.hasOwnProperty(name)) {129 invariant(130 specPolicy === SpecPolicy.DEFINE_MANY ||131 specPolicy === SpecPolicy.DEFINE_MANY_MERGED,132 'ReactCompositeComponentInterface: You are attempting to define ' +133 '`%s` on your component more than once. This conflict may be due ' +134 'to a mixin.',135 name136 );137 }138}139function validateTypeDef(Constructor, typeDef, location) {140 for (var propName in typeDef) {141 if (typeDef.hasOwnProperty(propName)) {142 invariant(143 typeof typeDef[propName] == 'function',144 '%s: %s type `%s` is invalid; it must be a function, usually from ' +145 'React.PropTypes.',146 Constructor.displayName || 'ReactCompositeComponent',147 ReactPropTypeLocationNames[location],148 propName149 );150 }151 }152}153/**154 * Creates a function that invokes two functions and merges their return values.155 *156 * @param {function} one Function to invoke first.157 * @param {function} two Function to invoke second.158 * @return {function} Function that invokes the two argument functions.159 * @private160 */161function createMergedResultFunction(one, two) {162 return function mergedResult() {163 var a = one.apply(this, arguments);164 var b = two.apply(this, arguments);165 if (a == null) {166 return b;167 } else if (b == null) {168 return a;169 }170 return mergeObjectsWithNoDuplicateKeys(a, b);171 };172}173/**174 * Creates a function that invokes two functions and ignores their return vales.175 *176 * @param {function} one Function to invoke first.177 * @param {function} two Function to invoke second.178 * @return {function} Function that invokes the two argument functions.179 * @private180 */181function createChainedFunction(one, two) {182 return function chainedFunction() {183 one.apply(this, arguments);184 two.apply(this, arguments);185 };186}187/**188 * Merge two objects, but throw if both contain the same key.189 *190 * @param {object} one The first object, which is mutated.191 * @param {object} two The second object192 * @return {object} one after it has been mutated to contain everything in two.193 */194function mergeObjectsWithNoDuplicateKeys(one, two) {195 invariant(196 one && two && typeof one === 'object' && typeof two === 'object',197 'mergeObjectsWithNoDuplicateKeys(): Cannot merge non-objects'198 );199 objMap(two, function(value, key) {200 invariant(201 one[key] === undefined,202 'mergeObjectsWithNoDuplicateKeys(): ' +203 'Tried to merge two objects with the same key: %s',204 key205 );206 one[key] = value;207 });208 return one;209}210function mixStaticSpecIntoComponent(Constructor, statics) {211 if (!statics) {212 return;213 }214 for (var name in statics) {215 var property = statics[name];216 if (!statics.hasOwnProperty(name) || !property) {217 return;218 }219 var isInherited = name in Constructor;220 var result = property;221 if (isInherited) {222 var existingProperty = Constructor[name];223 var existingType = typeof existingProperty;224 var propertyType = typeof property;225 invariant(226 existingType === 'function' && propertyType === 'function',227 'ReactCompositeComponent: You are attempting to define ' +228 '`%s` on your component more than once, but that is only supported ' +229 'for functions, which are chained together. This conflict may be ' +230 'due to a mixin.',231 name232 );233 result = createChainedFunction(existingProperty, property);234 }235 Constructor[name] = result;236 }237}238/**239 * Custom version of `mixInto` which handles policy validation and reserved240 * specification keys when building `ReactCompositeComponent` classses.241 */242function mixSpecIntoComponent(Constructor, spec) {243 invariant(244 !React.isValidClass(spec),245 'ReactCompositeComponent: You\'re attempting to ' +246 'use a component class as a mixin. Instead, just use a regular object.'247 );248 invariant(249 !React.isValidComponent(spec),250 'ReactCompositeComponent: You\'re attempting to ' +251 'use a component as a mixin. Instead, just use a regular object.'252 );253 var proto = Constructor.prototype;254 for (var name in spec) {255 var property = spec[name];256 if (!spec.hasOwnProperty(name)) {...

Full Screen

Full Screen

feact.js

Source:feact.js Github

copy

Full Screen

...10 FeactReconciler.performUpdateIfNecessary(internalInstance);11 }12 FeactReconciler.performUpdateIfNecessary(internalInstance);13};14function mixSpecIntoComponent(Constructor, spec) {15 const proto = Constructor.prototype;16 for (const key in spec) {17 proto[key] = spec[key];18 }19}20const Feact = {21 createClass(spec) {22 // создали конструктор компонента для пропсов23 function Constructor(props) {24 this.props = props;25 const initialState = this.getInitialState ? this.getInitialState() : null;26 this.state = initialState;27 }28 //добавляем все метор компонента в конструктор29 Constructor.prototype = new FeactComponent();30 mixSpecIntoComponent(Constructor, spec);31 return Constructor;32 },33 createElement(type, props, children) {34 const element = {35 type,36 props: props || {}37 };38 if (children) {39 element.props.children = children;40 }41 return element;42 },43 render(element, container) {44 const prevComponent = getTopLevelComponentContainer(container)...

Full Screen

Full Screen

ReactClass.js

Source:ReactClass.js Github

copy

Full Screen

1// ReactClass.js2var ReactComponent = require('ReactComponent')3var ReactElement = require('ReactElement')4var invariant = require('invariant')5function mixSpecIntoComponent(Constructor, spec) {6 if (!spec) {7 return;8 }9 invariant(10 typeof spec !== "function",11 "ReactClass: You're attempting to " +12 "use a component class or function as a mixin. Instead, just use a " +13 "regular object."14 );15 invariant(16 !ReactElement.isValidElement(spec),17 "ReactClass: You're attempting to " +18 "use a component as a mixin. Instead, just use a regular object."19 );20 var proto = Constructor.prototype;21 var autoBindPairs = proto.__reactAutoBindPairs;22 for (var name in spec) {23 if (!spec.hasOwnProperty(name)) {24 continue;25 }26 var property = spec[name];27 // var isAlreadyDefined = proto.hasOwnProperty(name);28 // Setup methods on prototype:29 // The following member methods should not be automatically bound:30 // 1. Expected ReactClass methods (in the "interface").31 // 2. Overridden methods (that were mixed in).32 // var isReactClassMethod = ReactClassInterface.hasOwnProperty(name);33 // var isFunction = typeof property === 'function'34 // var shouldAutoBind = isFunction && !isReactClassMethod && !isAlreadyDefined && spec.autobind !== false;35 // 省略了验证保留方法和 mixin 的逻辑36 proto[name] = property;37 }38}39var ReactClass = {40 createClass: function (spec) {41 var Constructor = function (props, context, updater) {42 this.props = props;43 this.context = context;44 // this.refs = emptyObject;45 // this.updater = updater || ReactNoopUpdateQueue;46 this.state = null;47 // ReactClasses doesn't have constructors. Instead, they use the48 // getInitialState and componentWillMount methods for initialization.49 var initialState = this.getInitialState ? this.getInitialState() : null;50 this.state = initialState;51 };52 Constructor.prototype = new ReactClassComponent();53 Constructor.prototype.constructor = Constructor;54 Constructor.prototype.__reactAutoBindPairs = [];55 mixSpecIntoComponent(Constructor, spec);56 return Constructor;57 },58};59var ReactClassComponent = function () {};60Object.assign(ReactClassComponent.prototype, ReactComponent.prototype);...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...16 mixins && mixins.length > 0,17 'You should provide at least one mixin'18 );19 for (var i = 0; i < mixins.length; i++) {20 mixSpecIntoComponent(this, mixins[i]);21 }22};23ReactComponentBase.prototype = React.createClass( { render: function () {} }).componentConstructor.prototype;24if ("production" !== process.env.NODE_ENV) {25 //debug membrne is really not compatible with our way of doing things26 ReactComponentBase.prototype = Object.getPrototypeOf(ReactComponentBase.prototype);27}28delete ReactComponentBase.prototype.render;29exports.ReactComponentBase = ReactComponentBase;30function autoBindMethods(constructor) {31 var proto = constructor.prototype,32 name;33 34 for (name in proto) {...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { mixSpecIntoComponent } = require('@playwright/test');2const { it, expect } = mixSpecIntoComponent('my-component');3it('should render', async ({ page }) => {4 await page.setContent('<my-component></my-component>');5 const content = await page.textContent('my-component');6 expect(content).toBe('Hello, World! I\'m');7});8const { mixSpecIntoComponent } = require('@playwright/test');9const { it, expect } = mixSpecIntoComponent('my-component');10it('should render', async ({ page }) => {11 await page.setContent('<my-component></my-component>');12 const content = await page.textContent('my-component');13 expect(content).toBe('Hello, World! I\'m');14});15import { mixSpecIntoComponent } from '@playwright/test';16const { it, expect } = mixSpecIntoComponent('my-component');17it('should render', async ({ page }) => {18 await page.setContent('<my-component></my-component>');19 const content = await page.textContent('my-component');20 expect(content).toBe('Hello, World! I\'m');21});22import { mixSpecIntoComponent } from '@playwright/test';23const { it, expect } = mixSpecIntoComponent('my-component');24it('should render', async ({ page }) => {25 await page.setContent('<my-component></my-component>');26 const content = await page.textContent('my-component');27 expect(content).toBe('Hello, World! I\'m');28});29import { mixSpecIntoComponent } from '@playwright/test';30const { it, expect } = mixSpecIntoComponent('my-component');31it('should render', async ({ page }) => {32 await page.setContent('<my-component></my-component>');33 const content = await page.textContent('my-component');34 expect(content).toBe('Hello, World! I\'m');35});36const { mix

Full Screen

Using AI Code Generation

copy

Full Screen

1const { mixSpecIntoComponent } = require('playwright/lib/internal/specMixins');2const { Page } = require('playwright/lib/server/page');3mixSpecIntoComponent(Page);4const { test, expect } = require('@playwright/test');5const { Page } = require('playwright/lib/server/page');6test.describe('test', () => {7 test('test', async ({ page }) => {8 await page.click('text=Get started');9 await page.click('text=Docs');10 await page.click('text=API');11 await page.click('text=Page');12 await page.click('text=Page.click');13 await page.click('text=See also');14 await page.click('text=Page.fill');15 await page.click('text=See also');16 await page.click('text=Page.focus');17 await page.click('text=See also');18 await page.click('text=Page.hover');19 await page.click('text=See also');20 await page.click('text=Page.press');21 await page.click('text=See also');22 await page.click('text=Page.selectOption');23 await page.click('text=See also');24 await page.click('text=Page.setContent');25 await page.click('text=See also');26 await page.click('text=Page.type');27 await page.click('text=See also');28 await page.click('text=Page.waitForFunction');29 await page.click('text=See also');30 await page.click('text=Page.waitForNavigation');31 await page.click('text=See also');32 await page.click('text=Page.waitForRequest');33 await page.click('text=See also');34 await page.click('text=Page.waitForResponse');35 await page.click('text=See also');36 await page.click('text=Page.waitForSelector');37 await page.click('text=See also');38 await page.click('text=Page.waitForTimeout');39 await page.click('text=See also');40 await page.click('text=Page.waitForURL');41 await page.click('text=See also');42 await page.click('text=Page.waitForXPath');43 await page.click('text=See also');44 await page.click('text=Page');45 await page.click('text=Page.accessibility');46 await page.click('text=Page.addInitScript

Full Screen

Using AI Code Generation

copy

Full Screen

1const { mixSpecIntoComponent } = require('playwright');2const mySpec = {3 myCustomMethod: async function () {4 console.log('my custom method');5 }6};7mixSpecIntoComponent(mySpec);8const { test } = require('@playwright/test');9test.describe('Test', () => {10 test('my test', async ({ page }) => {11 await page.myCustomMethod();12 });13});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { mixSpecIntoComponent } = require('@playwright/test');2const { Page } = require('@playwright/test');3const { Page } = require('@playwright/test');4class LoginPage extends Page {5 constructor(page) {6 super(page);7 }8 async login(username, password) {9 await this.page.fill('#username', username);10 await this.page.fill('#password', password);11 await this.page.click('button');12 }13}14mixSpecIntoComponent(LoginPage);15const { Page } = require('@playwright/test');16class LoginPage extends Page {17 constructor(page) {18 super(page);19 }20 async login(username, password) {21 await this.page.fill('#username', username);22 await this.page.fill('#password', password);23 await this.page.click('button');24 }25}26mixSpecIntoComponent(LoginPage);27test.describe('Login', () => {28 test('should login with valid credentials', async ({ page }) => {29 const loginPage = new LoginPage(page);30 await loginPage.login('admin', 'admin');31 });32});33test.describe('Login', () => {34 test('should login with valid credentials', async ({ page }) => {35 const loginPage = new LoginPage(page);36 await loginPage.login('admin', 'admin');37 });38});39test.describe('Login', () => {40 test('should login with valid credentials', async ({ page }) => {41 const loginPage = new LoginPage(page);42 await loginPage.login('admin', 'admin');43 });44});45test.describe('Login', () => {46 test('should login with valid credentials', async ({ page }) => {47 const loginPage = new LoginPage(page);48 await loginPage.login('admin', 'admin');49 });50});51test.describe('Login', () => {52 test('should login with valid credentials', async ({ page }) => {53 const loginPage = new LoginPage(page);54 await loginPage.login('admin', 'admin');55 });56});57test.describe('Login', () => {58 test('should login with valid credentials', async ({ page }) => {59 const loginPage = new LoginPage(page);60 await loginPage.login('admin', 'admin');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { mixSpecIntoComponent } = require('@playwright/test/lib/test');2const { test } = require('@playwright/test');3const customSpec = {4 test: async ({ page }) => {5 await page.waitForSelector('text=Get started');6 const title = page.locator('text=Get started');7 await title.click();8 await page.waitForSelector('text=TypeScript');9 const title2 = page.locator('text=TypeScript');10 await title2.click();11 await page.waitForSelector('text=Playwright');12 const title3 = page.locator('text=Playwright');13 await title3.click();14 },15};16mixSpecIntoComponent(test, customSpec);17test('test', async ({ page }) => {18 await page.waitForSelector('text=Get started');19 const title = page.locator('text=Get started');20 await title.click();21 await page.waitForSelector('text=TypeScript');22 const title2 = page.locator('text=TypeScript');23 await title2.click();24 await page.waitForSelector('text=Playwright');25 const title3 = page.locator('text=Playwright');26 await title3.click();27});28test('test', async ({ page }) => {29 await page.waitForSelector('text=Get started');30 const title = page.locator('text=Get started');31 await title.click();32 await page.waitForSelector('text=TypeScript');33 const title2 = page.locator('text=TypeScript');34 await title2.click();35 await page.waitForSelector('text=Playwright');36 const title3 = page.locator('text=Playwright');37 await title3.click();38});39test('test', async ({ page }) => {40 await page.waitForSelector('text=Get started');41 const title = page.locator('text=Get started');42 await title.click();43 await page.waitForSelector('text=TypeScript');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { mixSpecIntoComponent } = require('playwright/lib/api');2const spec = require('./spec');3mixSpecIntoComponent(spec);4const { test } = require('@playwright/test');5test('test', async ({ page }) => {6 await page.click('text=Get Started');7 await page.click('text=Docs');8 await page.click('text=API');9 await page.click('text=class: BrowserType');10 await page.click('text=launch');11 await page.click('text=launchPersistentContext');12});13const { spec } = require('playwright/lib/api');14module.exports = spec.mixin('browserType', ['launchPersistentContext'], (base, type) => {15 return class extends base {16 async launchPersistentContext(userDataDir, options) {17 const context = await base.launchPersistentContext.call(this, userDataDir, options);18 return context;19 }20 };21});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { mixSpecIntoComponent } = require('playwright-internal');2const spec = require('./spec.js');3mixSpecIntoComponent(spec, 'my-component');4module.exports = {5 properties: {6 name: {7 }8 },9 <div>Hello, {{name}}</div>10};11 const component = document.querySelector('my-component');12 console.log(component.textContent);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { mixSpecIntoComponent } = require('playwright-internal');2const { ButtonSpec } = require('./button.spec');3const { Button } = require('./button');4const { ButtonRenderer } = require('./button.renderer');5const { ButtonRendererSpec } = require('./button.renderer.spec');6const { ButtonDriver } = require('./button.driver');7const { ButtonDriverSpec } = require('./button.driver.spec');8const { ButtonDriverRenderer } = require('./button.driver.renderer');9const { ButtonDriverRendererSpec } = require('./button.driver.renderer.spec');10const { ButtonDriverRendererDriver } = require('./button.driver.renderer.driver');11const { ButtonDriverRendererDriverSpec } = require('./button.driver.renderer.driver.spec');12const { ButtonDriverRendererDriverRenderer } = require('./button.driver.renderer.driver.renderer');13const { ButtonDriverRendererDriverRendererSpec } = require('./button.driver.renderer.driver.renderer.spec');14const { ButtonDriverRendererDriverRendererDriver } = require('./button.driver.renderer.driver.renderer.driver');15const { ButtonDriverRendererDriverRendererDriverSpec } = require('./button.driver.renderer.driver.renderer.driver.spec');16const { ButtonDriverRendererDriverRendererDriverRenderer } = require('./button.driver.renderer.driver.renderer.driver.renderer');17const { ButtonDriverRendererDriverRendererDriverRendererSpec } = require('./button.driver.renderer.driver.renderer.driver.renderer.spec');18const { ButtonDriverRendererDriverRendererDriverRendererDriver } = require('./button.driver.renderer.driver.renderer.driver.renderer.driver');19const { ButtonDriverRendererDriverRendererDriverRendererDriverSpec } = require('./button.driver.renderer.driver.renderer.driver.renderer.driver.spec');20const { ButtonDriverRendererDriverRendererDriverRenderer

Full Screen

Playwright tutorial

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.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful