Repository navigation
Conversation
…d row
makeLegend()'s loop set wrapper.id = 'container' on every iteration,
producing 9 sibling elements sharing the same id, which is invalid HTML
and makes document.getElementById('container') unreliable. Use a CSS
class instead. Also removed a no-op line that reassigned the legend
element's id to the id just used to look it up.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Motivation
makeLegend()insamples/dds-datasets-point/index.tsbuilt the legend by looping once per fur color (9 colors) and settingwrapper.id = 'container'on every iteration, producing 9 sibling<div id="container">elements. HTML ids must be unique per document, sodocument.getElementById('container')can only ever return the first of the 9 rows, and this breaks under any stricter HTML validator or linter even though it happened to render correctly today because the CSS used an ID selector (#legend #container) that browsers still match against every element.The function also had a redundant no-op line.
legend!.id = 'legend';runs immediately afterdocument.getElementById('legend'), reassigning the element's id to the exact id just used to look it up, which is leftover or copy-paste code with no effect.What I have done
I replaced
wrapper.id = 'container'withwrapper.classList.add('legend-row')insamples/dds-datasets-point/index.ts, so each legend row gets a class instead of a duplicate id.Also I removed the no-op
legend!.id = 'legend';line, and updatedsamples/dds-datasets-point/style.cssto target#legend .legend-rowinstead of#legend #container.Test Plans
npx tsc --noEmit -p samples/dds-datasets-point/tsconfig.jsonto confirm the sample still type checks.#legend #containerCSS still applying.class="legend-row"and no duplicateid="container"attributes remain.Test Results
npx tsc --noEmit -p samples/dds-datasets-point/tsconfig.jsonpassed with no errors.