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

Check for document fragments in toElement #204

Merged
merged 1 commit into from
Feb 1, 2017
Merged

Check for document fragments in toElement #204

merged 1 commit into from
Feb 1, 2017

Conversation

julien
Copy link
Contributor

@julien julien commented Jan 31, 2017

Hi,

I did check the guidlines (and hope I didn't miss anything) but the gulp lint task did output a lot of warnings, before these changes, I wasn't sure if that was expected.

Thanks

@eduardolundgren
Copy link
Contributor

what happens if the document fragment is composed by multiple nodes and you invoke toElement on it?

@yuchi
Copy link
Contributor

yuchi commented Jan 31, 2017

You get the fragment itself. It works as an Element, a single one.

@julien
Copy link
Contributor Author

julien commented Jan 31, 2017

@eduardolundgren yes like @yuchi says, if you do something like this

var frag1 = document.createDocumentFragment();
var p = document.createElement('p');
var frag2 = document.createDocumentFragment();

var numElements = 1000;
for (var i = 0; i < numElements; i++) {
  var d = document.createElement('div');
  var s = 'child-' + i + 1;
  d.setAttribute('id', s);

  frag2.appendChild(d);
}
p.appendChild(frag2);
frag1.appendChild(p);

// assert.strictEqual(frag1, dom.toElement(frag1));

Then dom.toElement(frag1) returns you the frag1 element, which is just another element.

@yuchi
Copy link
Contributor

yuchi commented Jan 31, 2017

…is just an Element-like API.

@eduardolundgren
Copy link
Contributor

I am familiar with the document fragment api, for a moment I though the pull request was converting a fragment to an element, therefore my question. It's clear now that it's just returning it. Thank you guys.

@eduardolundgren eduardolundgren merged commit 6f004bd into metal:master Feb 1, 2017
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