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

Misc features #729

Merged
merged 2 commits into from
Oct 5, 2012
Merged

Misc features #729

merged 2 commits into from
Oct 5, 2012

Conversation

benlangfeld
Copy link
Contributor

No description provided.

@flavorjones
Copy link
Member

Thanks, I'll take a look today.

@@ -258,7 +259,12 @@ def [] name
###
# Set the attribute value for the attribute +name+ to +value+
def []= name, value
set name.to_s, value
if value.nil?
remove_attribute name.to_s
Copy link
Member

Choose a reason for hiding this comment

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

If we wan't this to quack like a hash, shouldn't we implement delete rather than having a magic value mean delete? I'm not really excited about the idea of calling a setter that could possibly have the side effect of deleting something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The question is why you would ever want to render an XML node with an
attribute present but empty.

Regards,
Ben Langfeld

Em 13 Jul 2012, às 19:05, Aaron Patterson
[email protected]
escreveu:

@@ -258,7 +259,12 @@ def [] name
###
# Set the attribute value for the attribute +name+ to +value+
def []= name, value

  •    set name.to_s, value
    
  •    if value.nil?
    
  •      remove_attribute name.to_s
    

If we wan't this to quack like a hash, shouldn't we implement delete rather than having a magic value mean delete? I'm not really excited about the idea of calling a setter that could possibly have the side effect of deleting something.


Reply to this email directly or view it on GitHub:
https://github.com/sparklemotion/nokogiri/pull/729/files#r1160798

Copy link
Member

Choose a reason for hiding this comment

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

Your scheme definition could demand the presence of the attribute but not define a value. Sorry, I won't accept this feature without a stronger argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll move this up into a decorator.

@benlangfeld
Copy link
Contributor Author

Objectionable content removed. Any thoughts on the remainder?

@benlangfeld
Copy link
Contributor Author

Can someone review this please?

@benlangfeld
Copy link
Contributor Author

I'd really love to get some of this in.

@benlangfeld
Copy link
Contributor Author

No breaking changes here. @flavorjones @jvshahid merge?

@flavorjones
Copy link
Member

I don't think the symbol-to-string conversion is useful. There's also a test around non-string attribute values, which doesn't have any corresponding code changes. Can you tell me a little more about that?

In the future, pull requests should not contain reversions, and should not contain multiple features. Following this convention will make it easier to communicate about the pull request and will speed up merging if the PR is accepted.

@benlangfeld
Copy link
Contributor Author

Option 1:

foo.xpath 'ns:bar', 'ns' => 'baz'

Option 2:

foo.xpath 'ns:bar', ns: 'baz'

The latter is better in my view and is what I want my code to look like. You might not like it, but it doesn't do you any harm. Therefore, there is no logical reason not to merge it.

As for the non-string attribute values, there is a change: https://github.com/sparklemotion/nokogiri/pull/729/files#L0R261. Without that change, the test fails.

@flavorjones
Copy link
Member

Fine. Please rebase so whitespace changes and revert commits aren't present.

@benlangfeld
Copy link
Contributor Author

Rebased on master.

flavorjones added a commit that referenced this pull request Oct 5, 2012
XPath lookup with namespaces with hash keys and XML::Node#[]= should stringify values
@flavorjones flavorjones merged commit dae5dcb into sparklemotion:master Oct 5, 2012
@flavorjones
Copy link
Member

Merged, thanks.

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.

3 participants