Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Iron flex guide does not show code #207

Open
arthurevans opened this issue Nov 2, 2015 · 9 comments
Open

Iron flex guide does not show code #207

arthurevans opened this issue Nov 2, 2015 · 9 comments

Comments

@arthurevans
Copy link
Contributor

From @hugelgupf on October 29, 2015 14:52

I'm assuming that those grey boxes are not supposed to be empty:

screen shot 2015-10-29 at 7 49 43 am

Using up-to-date Chrome on OS X.

Copied from original issue: Polymer/old-docs-site#1395

@arthurevans
Copy link
Contributor Author

From @jeffposnick on October 29, 2015 17:45

FWIW, I was seeing this as well with Chrome 46 a few days ago, but I can't reproduce it now on the production site.

Running a dev version of the site, you can reproduce it by removing the <prism-highlighter> from the page. If you can reproduce this now, @hugelgupf, do you see any errors in the Chrome DevTools console?

image

@arthurevans
Copy link
Contributor Author

From @hugelgupf on October 29, 2015 17:59

So first of all, I just opened it up again, and I cannot reproduce. Luckily, I still have the old tab open. The only thing in the console is this:

/deep/ combinator is deprecated. See https://www.chromestatus.com/features/6750456638341120 for more details. elements.build.js:40898

Is there something that processes the stuff in code tags to produce the highlighting that could be failing during the build process? I've attached two screenshots comparing the broken/working state of a specific code tag, and it looks like on the broken one, the code that's supposed to be displayed is actually "executed". (Not sure I have the right word for this -- rendered?)
screen shot 2015-10-29 at 10 56 30 am
screen shot 2015-10-29 at 10 56 15 am

@arthurevans
Copy link
Contributor Author

From @jeffposnick on October 29, 2015 18:25

This portion of the <page-guide> source looks fishy to me:

var event = this.fire('syntax-highlight', {code: code});
if (event.detail.code && !els[i].highlighted) {
  els[i].highlighted = true;
  els[i].innerHTML = event.detail.code;
}

AFAIK, this.fire() doesn't do anything synchronous. It will raise an event, which is handled asynchronously by any event listeners. Unless I'm misreading things, that code will only work as expected if the syntax-highlight event handler has already run by the time the if() statement is encountered, so there's a race condition.

@arthurevans
Copy link
Contributor Author

Yep, rendered is right. If you still have the bad tab open, can you try running this in the console?

var h = document.querySelector('prism-highlighter');
h.__isPolymerInstance__

If it returns true, it looks like the Prism highlighter element exists on the page and is upgraded, but didn't highlight (perhaps because of a timing issue). If it throws an error, the element is missing or hasn't been upgraded.

fire is synchronous and returns the custom event fired, so you can do things like:

var event = this.fire('event-name');
if (event && !event.defaultPrevented) { ... } 

Or words to that effect. See:

https://github.com/Polymer/polymer/blob/master/src/standard/utils.html#L212

But it occurs to me that if contentChanged is called before the prism-element's attached method, we'd see this issue, because it would never receive the event. I'm not sure whether that code path is possible, but it's worth investigating...

https://github.com/PolymerElements/prism-element/blob/master/prism-highlighter.html#L44

@arthurevans
Copy link
Contributor Author

From @hugelgupf on October 29, 2015 18:45

Console output:

> var h = document.querySelector('prism-highlighter');
undefined
> h.__isPolymerInstance__
true

(Sorry I can't be of more help, hadn't done web dev in ages before starting with polymer.)

@arthurevans
Copy link
Contributor Author

From @jeffposnick on October 29, 2015 18:50

Huh, I wouldn't have thought the underlying dispatchEvent() was synchronous, but yep, you're right @arthurevans. Sorry for the red herring!

@arthurevans
Copy link
Contributor Author

No, that's plenty to go on. I believe it must be a timing issue.

@jeffposnick I know, right? Need to open a bug to make that clear in the docs.

@arthurevans
Copy link
Contributor Author

@frankiefu @blasten Weird intermittent catalog bug -- could this be a timing issue?

@dandv
Copy link

dandv commented Mar 1, 2016

I see this as well at https://elements.polymer-project.org/guides/flex-layout right now

image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants