-
Notifications
You must be signed in to change notification settings - Fork 20
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
Cannot replace root elements in html-fragment #65
Comments
If you're loading an HTML fragment the top level elements should be automatically selected. Here is a problem with replace() however. At current implementation required the node to have a parent that is an element node. But in this case it is the document node. I added a test and a fix. |
I have tried the new commit. Code:
Expected:
Actual:
In jquery:
Result:
And with the following Code, the result is also wrong:
Expected:
Actual:
|
filter() reduces the current selection. You're filtering the current selection for any node that is a 'p' or has a 'p' descendant. The div has a p descendant so it matches. The div is replaced. Why don't you use find()? |
But the result is different from the jquery version as I posted above. The reason why I don't use find because I can't find the root elements. code:
Result:
the first it finds is the p inside the div. |
Hi, any updates? |
The actual problem left seems to be with the CSS Selector to Xpath conversion. I added some tests using specific Xpath expressions and it works: This is difficult to debug because the conversion is not part of FluentDOM itself and an edge case. |
As there is no root, how can I search the
p
and replace it?I tired to use
filter
andreplace
, but it will remove all my matched elements.Expected:
Actual:
The text was updated successfully, but these errors were encountered: