pugjs / pug

Pug – robust, elegant, feature rich template engine for Node.js
https://pugjs.org
21.68k stars 1.95k forks source link

script(src='http://code.jquery.com/jquery.js') messes up the DOM #1166

Closed Avec112 closed 11 years ago

Avec112 commented 11 years ago

script(src='http://code.jquery.com/jquery.js')- FAIL (URL is valid) script(src='http://code.jquery.com/whatever/jquery.js')- OK script(src='http://code.jquery.com/whatever.js')- OK script(src='http://whatever.jquery.com/jquery.js')- OK script(src='http://code.whatever.com/jquery.js')- OK script(src='http://code.jquery.whatever/jquery.js')- OK script(src='http://backbonejs.org/backbone-min.js')-OK (URL is valid)

I thought that maybe only valid url's failed but the last line proved that not to be the case. Somehow the url cannot be http://code.jquery.com/jquery.js. Everything else seem to work just fine.

The first URL reference messes up the DOM to something like this

...
   <script src="http://code.jquery.com/jquery.js"></script>
   <style type="text/css"></style> <!-- Where did this come from?  -->
</head>
<body style>  <!-- Where did this come from? -->
...

I can get around the problem by having the the jquery.js referenced from a local directory. script(src='/whatever/jquery.js')- OK

Avec112 commented 11 years ago

Nope. Seems script(src='/js/jquery.js') do not work either. Same messed up DOM.

How can this be?

ForbesLindesay commented 11 years ago

You need to use view page source, not the dom inspector. I've tested this out and:

script(src='http://code.jquery.com/jquery.js')
<script src="http://code.jquery.com/jquery.js"></script>
Avec112 commented 11 years ago

Hmmm. Strange. I did not mention in but I used Chrome (developer tools DOM inspector). View page source showed the DOM correctly but it do not explain why the DOM inspector shows something else.

In firebug it looks ok by the way.

So where is the bug, in Chrome developer tools?

vendethiel commented 11 years ago

That's not a "bug", just a hook for you.

Avec112 commented 11 years ago

Nami-Doc I do not understand.

If Chrome Developer Tools and Firebug shows two different DOMs would it not be natural to think there is a bug somewhere?

When I include a script tag a sure do not expect at style tag apear under the script tag. And <body style>whats that about?

vendethiel commented 11 years ago

That's to allow you to add styling easily. Like the $ defined in chrome's RE

vendethiel commented 11 years ago

PL, that's just to ease the developers.

(sorry, can't edit from my phone)