Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take paymentRequestID in constructor #413

Closed
wants to merge 2 commits into from

Conversation

rvm4
Copy link
Collaborator

@rvm4 rvm4 commented Feb 7, 2017

We appear to use "?" and "optional" interchangeably to signify nullability in this webIDL definition. Is that intentional or should I convert the whole thing to one way or the other?

We appear to use "?" and "optional" interchangeably to signify nullability in this webIDL definition. Is that intentional or should I convert the whole thing to one way or the other?
@rsolomakhin
Copy link
Collaborator

The optional keyword does not mean nullability, it means omitability. Suppose your have this IDL:

void func(optional DOMString stuff);

Then your JavaScript code func(null) will result in stuff === "null". That's a non-null string of 4 characters whose value is"null", not an actual null string. This IDL allows calling func().

Suppose your have this IDL instead:

void func(DOMString? stuff);

Then your JavaScript code func(null) will result in stuff === null. That's the actual null string. This IDL does not allow calling func().

@rvm4
Copy link
Collaborator Author

rvm4 commented Feb 7, 2017

Oh, gotcha, makes sense. You asked in the issue for the paymentRequestID to be optional though, which means putting it at the end of the constructor after the options. I don't think this is desirable because my intuition is that many clients will use the paymentRequestID field. Are we okay with it be nullable and at the front of the constructor in order to promote usage?

@rsolomakhin
Copy link
Collaborator

👎 to nullable at the front of the constructor, because we don't have the data to backup the intuition of many clients using the new field. Let's use the optional keyword. OK to keep at the front. In practice this means that there will be 4 constructors:

PaymentRequest(PaymentMethodData methodData, PaymentDetails details);
PaymentRequest(PaymentMethodData methodData, PaymentDetails details, PaymentOptions options);
PaymentRequest(DOMString id, PaymentMethodData methodData, PaymentDetails details);
PaymentRequest(DOMString id, PaymentMethodData methodData, PaymentDetails details, PaymentOptions options);

@rvm4
Copy link
Collaborator Author

rvm4 commented Feb 7, 2017

Oh duh, I have been writing in a one-constructor language for too long :/

@rvm4
Copy link
Collaborator Author

rvm4 commented Feb 7, 2017

Shall I go ahead and merge then? Seems like it.

@rsolomakhin
Copy link
Collaborator

As long as your newly introduced line-breaks are not reflected in the resulting HTML, LGTM 👍

@rvm4
Copy link
Collaborator Author

rvm4 commented Feb 7, 2017

I have no idea how to test that other than to git pull and manually verify. I can remove the line breaks if we prefer a nasty line wrap.

@rsolomakhin
Copy link
Collaborator

Line breaks are technically OK if we move methodData one line above, together with its type :-)

@domenic
Copy link
Collaborator

domenic commented Feb 7, 2017

This should definitely not be merged as-is. It needs to update the constructor algorithm to actually store the paymentRequestID somewhere.

@rvm4
Copy link
Collaborator Author

rvm4 commented Feb 8, 2017

Good call @domenic, I believe I have address that as well as the spacing from @rsolomakhin.

@marcoscaceres
Copy link
Member

@rvm4, I think the paymentRequestID needs to be part of the PaymentDetails object, no?

[Constructor(sequence<PaymentMethodData> methodData, PaymentDetails details, optional PaymentOptions options),
SecureContext]
[Constructor(
optional DOMString paymentRequestID,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's invalid Web IDL to have optional arguments that are not at the end of the parameter list. You'll need multiple [Constructor] annotations, to trigger the overload resolution algorithm. Then you'll need to write two separate constructor algorithms (probably factoring out some shared logic).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should just add this to PaymentDetails or PaymentOptions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of putting it in PaymentDetails or PaymentOptions because it relegates the field to be second class.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is second class. It's an optional thing - that's not a value judgement. Making a mess by overloading the constructor doesn't seem very good to me - specially given how complicated it already is to construct these objects.

@@ -556,6 +560,8 @@
</li>
<li>Let <var>request</var> be a new <a>PaymentRequest</a>.
</li>
<li>Set <var>request</var>.<a>[[\paymentRequestID]]</a> to <var>paymentRequestID</var>.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, so now it is stored with the object. But it is never used by the entire spec, right? You need to wire up the getter for the paymentRequestID property to return the value of the [[paymentRequestID]] internal slot.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. This ReSpec is also warning that paymentRequestId is not defined for this exact reason.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sigh...okay, I can do the multiple constructor thing.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest waiting on getting working group consensus on where it should go. It sounds like several people are very much in favor of putting it in PaymetnDetails or PaymentOptions, so any work on making it a separate argument would be wasted.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it might be easier/preferable to just put this in PaymentDetails. Any objection to that? Seems like less work. :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting this in payment details will naturally demote the importance of this field. Maybe this should be discussed in the f2f then.

@marcoscaceres
Copy link
Member

I'm still not sure what you mean by "demotion"? It's an optional parameter with equal importance to any other optional parameter, no?

@rvm4
Copy link
Collaborator Author

rvm4 commented Feb 22, 2017

Okay, please followup in PR 426 where I moved all this to the details dictionary.

@rvm4 rvm4 closed this Feb 22, 2017
@marcoscaceres marcoscaceres deleted the payment-request-id-in-constructor branch January 23, 2018 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants