Head tag keeps multiplying with empty contents #83

Closed
opened 2017-02-03 18:13:55 -05:00 by aurimus · 3 comments
aurimus commented 2017-02-03 18:13:55 -05:00 (Migrated from github.com)

Hi, any idea why this would be happening?

head_problem_pjax

var pjax = new Pjax({ selectors: ["head title", "body"] }) but it works the same if I remove the head title

Hi, any idea why this would be happening? ![head_problem_pjax](https://cloud.githubusercontent.com/assets/1052992/22612106/224a8ece-ea77-11e6-9b74-6ee7ff04c954.gif) `var pjax = new Pjax({ selectors: ["head title", "body"] })` but it works the same if I remove the `head title`
aurimus commented 2017-02-03 18:16:58 -05:00 (Migrated from github.com)

You can inspect it here also: http://saulesinterjerai.lt/ same problem same code

You can inspect it here also: http://saulesinterjerai.lt/ same problem same code
lacrioque commented 2017-11-08 04:01:39 -05:00 (Migrated from github.com)

Still an issue?

Still an issue?
BehindTheMath commented 2017-12-19 15:27:48 -05:00 (Migrated from github.com)

I believe this is being caused by the issue described here:

We can’t replace body.outerHTML or head.outerHTML. It creates a bug where a new body or new head are created in the DOM. If you set head.outerHTML, a new body tag is appended, so the DOM gets 2 bodys, & it break the switchFallback which replaces head & body.

See here for more information about why this happens.

The code there is supposed to prevent that by using this.switchElementsAlt() instead of the default outerHTML switch. However, I don't see switchElementsAlt() defined anywhere.

I believe this is being caused by the issue described [here](https://github.com/MoOx/pjax/blob/a7b584c469d412ae7333a795a0ac8d3616a96a1f/lib/proto/parse-options.js#L25-L28): >We can’t replace `body.outerHTML` or `head.outerHTML`. It creates a bug where a new `body` or new `head` are created in the DOM. If you set `head.outerHTML`, a new `body` tag is appended, so the DOM gets 2 `body`s, & it break the `switchFallback` which replaces `head` & `body`. See [here](https://stackoverflow.com/a/27854343/8037425) for more information about why this happens. The code [there](https://github.com/MoOx/pjax/blob/a7b584c469d412ae7333a795a0ac8d3616a96a1f/lib/proto/parse-options.js#L28-L34) is supposed to prevent that by using `this.switchElementsAlt()` instead of the default `outerHTML` switch. However, I don't see `switchElementsAlt()` defined anywhere.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: iLoveElysia/pjax#83