-
Notifications
You must be signed in to change notification settings - Fork 71
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
Adjust types to match exported functions #116
Conversation
Thank you for submitting this. I'm not all that knowledgeable about .d.ts files and wasn't aware that they could contain functions. Would you mind explaining how one makes use of those functions? One thing that I notice is that you are using I would also think that those would fail to work on non-native nodes, such as those from Especially given that last part, I'm inclined to think that it would probably be wiser to use duck typing and a handful of node type constants rather than relying on the global |
Indeed, duck typing does work better for this use-case. in BTW, since the TS refactor of |
Thank you for this update. I've sent you a pull request with some proposed changes and also made some comments. We should also have unit tests for the new functions you're adding. Can you include those in your PR? |
I've made the changes you've discussed. Side-note: I'd like to format your code, but I don't see a npm script to do so. What formatting tool do you use? |
Thank you. I've requested a few more changes to the unit tests, and there's a re-activated comment about the return types in the Until now, I've been careful to leave the whitespace in xpath.js undisturbed so as to not have a huge diff in the history, but I was thinking that it's about time that I added a prettify process. I can do that once this PR is merged. |
I'm sorry, I don't see these. Otherwise, I've made all the changes that I think you've requested. Thanks for your review! |
IIRC, eslint can format code and it is highly customizable, so you can just pick a style that most closely matches what you have now to minimize changes. |
@JLRishe , I can't easily tell from reading the code; can |
I'm referring to these comments:
I don't see any way that would work. I think what you're seeing is that module.exports.xpath = function (node, xpath) {
return select(xpath, node);
}; And |
Since they are "Pending", I don't see them. You have to complete the review for them to be visible to me :) |
That's weird. I thought I sent them the same way I sent all the previous comments. Hopefully they're visible now. |
They are. I'll resolve these as I push changes related to them. node-saml/xml-crypto#325 is now importing this PR at its HEAD so that I can make sure 100% of these changes are working in real code. I'll convert this to a Draft until it is ready to merge. Thanks again for your attention. |
@JLRishe , one of the tests is failing, and it isn't because of any code I wrote. It appears that ProcessingInstruction doesn't have a it('should correctly identify a Node of type ProcessingInstruction', () => {
var doc = parseXml('<book />');
var pi = doc.createProcessingInstruction('xml-stylesheet', 'href="mycss.css" type="text/css"');
assert.ok(xpath.isNodeLike(pi));
assert.ok(xpath.isProcessingInstruction(pi));
assert.ok(!xpath.isComment(pi));
}); Should have a |
The processing instruction in your test is being created by the It does indeed appear that the DOM 3 standard indicates that processing instructions should have a I think removing the |
Done: xmldom/xmldom#505 |
I've put up a PR to get this fixed in |
This PR has landed and is schedule for v0.9.0 release. Once that release happens, we can revisit this PR to adjust the |
This is now no longer needed since FWIW, I note that I installed I installed I installed I installed All that to say, the |
The xpath.js file, which is the only code that this package exports, does not use The tests use modern JavaScript, but the main file does not. I have been careful to ensure that the main code remains ES5 compliant (though I have just found that an incompatibility slipped in some time ago). I have just merged an ES5 validation script into the master branch. Please revert the change to the |
Done. I generated
Is there something you'd like to see broken out into multiple PRs? |
I would have preferred to have the node type test functions in a separate PR. If this were just the .d.ts changes, it could have been merged a lot sooner. But it's ok. Thank you for sticking through this PR. |
I'm not worried about the delay as the PR over at |
The new version is now published to npm. Thanks! |
that is strange to change the I think the return type of
BTW, if you make a breaking change, you should publish a MAJOR number version. |
@iahu I am sorry that this update is causing trouble for you. In this update, the type definitions were modified to be consistent with the actual behavior of the package's implementation. The actual behavior of the package's exported functions has not changed. The type definitions were previously incorrect and have been corrected. Per the XPath 1.0 spec, an XPath expression can evaluate to:
As you can see, it cannot evaluate to a set of strings, or to a null value. This package's The author of this PR has added several utility functions that can help to converge the result of Personally, I think |
after read a bit of the source code. I agree that, the current type declare fit the as my above comment, I want get the facts straight. I suggested to change the |
I'm reviewing this to make adjustments where needed. Are you hereby saying that |
The
selectWithResolver
type was missing from the type definitions. As I was looking, I noticed a few others things might be wrong. I think this should cover everything. I'll try it in thexml-crypto
project and report back when that migration is done. Until then, I'd like to get feedback.