-
Notifications
You must be signed in to change notification settings - Fork 14
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
Additional updates for “2.x” release. #213
Conversation
| -- | -- | `el.removeAttribute('foo'); // if “bar” is nullish` | | ||
| property | `<div .foo="${bar}"></div>` | `el.foo = bar;` | | ||
| content | `<div>${foo}</div>` | `el.append(document.createTextNode(foo)) // if “bar” is text` | | ||
| -- | -- | (see [content binding](#content-binding) for composition) | |
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.
Made the table a bit more wide so that the emulation code is proximal to the template code.
test/test-template-engine.js
Outdated
@@ -564,7 +564,7 @@ describe('html updaters', () => { | |||
|
|||
it('unsafe html', () => { | |||
const getTemplate = ({ content }) => { | |||
return html`<div id="target">${unsafe(content, 'html')}</div>`; | |||
return html`<div id="target">${unsafe(content)}</div>`; |
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.
The unsafe
updater gets much more simple.
@@ -1476,28 +1451,10 @@ describe('rendering errors', () => { | |||
|
|||
|
|||
describe('unsafe', () => { | |||
it('throws if used on an unexpected language', () => { |
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.
We don’t support unsafe
svg for now. We may choose to add this back in the future in some backwards-compatible way.
FYI — @klebba. |
b6050d7
to
bc23055
Compare
x-element.js
Outdated
// the template “strings” before, we also have to generate html, parse it, | ||
// and find out binding targets. Then, we commit the values by iterating over | ||
// our targets. Finally, we actually attach our new DOM into our node. | ||
static #inject(result, node, before) { |
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.
@klebba — Did some refactoring / renaming here since you called it out as confusing when you were looking things over yesterday. Hope it helps!
x-element.js
Outdated
TemplateEngine.#ready(result); | ||
TemplateEngine.#commit(result); | ||
TemplateEngine.#inject(result, node, { before: true }); | ||
TemplateEngine.#inject(result, node, true); |
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.
The ready + commit + inject
methods are collapsed into a single inject
method now.
x-element.js
Outdated
state.result = result; | ||
} else { | ||
TemplateEngine.#assign(state.result, result); | ||
TemplateEngine.#commit(state.result); | ||
TemplateEngine.#update(state.result, result); |
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.
The assign + commit
methods are collapsed into a single update
method now.
bc23055
to
69c8936
Compare
9b6a42a
to
f8bc37d
Compare
f8bc37d
to
9460060
Compare
Changes: * Deprecate `unsafeHTML` and `usafeSVG`. * Allow binding `DocumentFragment` as a value. * Tag every line in the “CHANGELOG.md” with an issue ticket. * Simplified formatting related to bindings in “TEMPLATES.md”. * Emit deprecation warnings for soon-to-be-gone interfaces. * Deprecate remaining updaters (e.g., “map”). * Ditch unecessary “weak maps”.† * Some performance improvements. † The search set for the weak maps we’re using gets untenable since it’s a flat list of pointers for _all_ results. It feels like a reasonable concession to hang data off of a unique symbol key. These are non-enumerable (unless specifically trying to enumerate symbols), which feels internal enough. Additionally, returning the values passed in by the user doesn’t feel like much of a leaking abstraction.
9460060
to
19367eb
Compare
Additional updates for “2.x” release.
Changes:
unsafeHTML
andusafeSVG
.DocumentFragment
as a value.† The search set for the weak maps we’re using gets untenable since it’s
a flat list of pointers for all results. It feels like a reasonable
concession to hang data off of a unique symbol key. These are
non-enumerable (unless specifically trying to enumerate symbols),
which feels internal enough. Additionally, returning the values passed
in by the user doesn’t feel like much of a leaking abstraction.