-
Notifications
You must be signed in to change notification settings - Fork 27
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
Render all child components and use data-ref element #87
Conversation
result.setAttribute(references.referenceAttribute, ref); | ||
// The element with `data-ref` is not always the parent, e.g. article. | ||
refEl = dom.find(parent, '[' + references.referenceAttribute + '=""]'); | ||
refEl.setAttribute(references.referenceAttribute, ref); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait, what's going on here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, http://localhost.dev.nymag.biz:3001/components/article/instances/pr-first.html responds with:
<main role="main">
<article class="article" data-ref="" itemscope itemtype="http://schema.org/Article">
...
We want data-ref to be added to the <article>
element not the <main>
element.
hmm, I could simplify the line to be refEl = dom.find(parent, '[' + references.referenceAttribute + ']');
Maybe the comment is confusing because of the use of "parent"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TakenPilot why does the above return with data-ref=""
rather than populating that value server-side?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, that's a good question.
Discussed with @yoshokatana and @TakenPilot and agreed: Assumption/requirement: the first element in a component should always have the This allows for easy replacement of components in byline-editor. (After this PR, the article template will need its data-ref moved up to the top element) |
👍 |
container.innerHTML = target.responseText; | ||
// The first element in a component always has the referenceAttribute. | ||
componentEl = dom.getFirstChildElement(container); | ||
componentEl.setAttribute(references.referenceAttribute, ref); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait, why is this setting it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of this #89
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is safe as long as we assume the data-ref is in the first element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's been doing this from the very beginning. Very old code. He just added a comment because it's unclear, so let's discuss tomorrow until everything is clear. I'll prepare.
I'll also add an explanation to an Issue somewhere to eventually be added to editor docs.
ok 👍 |
Render all child components and use data-ref element
This fixes the bug with overlays saving.
There were two problems:
data-ref
attribute.autosave broke overlay + settings form saving #64