Skip to content
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

Renderer.setText for platform-browser is broken after 2.2.x #13047

Closed
log2-hwan opened this issue Nov 23, 2016 · 6 comments
Closed

Renderer.setText for platform-browser is broken after 2.2.x #13047

log2-hwan opened this issue Nov 23, 2016 · 6 comments
Labels
area: core Issues related to the framework runtime regression Indicates than the issue relates to something that worked in a previous version

Comments

@log2-hwan
Copy link

log2-hwan commented Nov 23, 2016

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior
Renderer.setText function doesn't update element's text content.

Expected behavior
Renderer.setText function should update element's text content.

Minimal reproduction of the problem with instructions
Working version (2.1.2): http://plnkr.co/edit/jXl54wPrjcg4l6BYiv5a?p=preview
Broken version (2.2.2): http://plnkr.co/edit/CCpPqGU1YvVQZAKw5I4L?p=preview

Please tell us about your environment:

  • Angular version: 2.2.x

  • Browser: all

  • Language: TypeScript 2.0.3

@robwormald robwormald added area: core Issues related to the framework runtime severity3: broken labels Nov 23, 2016
@PatrickJS
Copy link
Member

PatrickJS commented Nov 23, 2016

here's a workaround until a patch is released

import { DomRenderer } from '@angular/platform-browser';
DomRenderer.prototype.setText = function fixSetText(renderNode: any, text: string): void {
  renderNode.textContent = text;
}

github-tipe-logo

@IgorMinar IgorMinar added regression Indicates than the issue relates to something that worked in a previous version and removed severity3: broken labels Nov 23, 2016
@tbosch
Copy link
Contributor

tbosch commented Nov 23, 2016

Renderer.setText was never meant to be used for elements, only for text nodes.
I.e. it still works to update text nodes, but not replace the text content of elements. So this works as intended.

To do this, just use elementRef.nativeElement.textContent = ... directly. This won't work on webworkers, but our webworker story is not complete yet (and also experimental), the most important part, custom render services, is still missing which will allow you to split your services into a UI and a worker part
(see #2409).

@tbosch tbosch closed this as completed Nov 23, 2016
@DzmitryShylovich
Copy link
Contributor

@tbosch

Renderer.setText was never meant to be used for elements, only for text nodes.
I.e. it still works to update text nodes, but not replace the text content of elements. So this works as intended.

what about dom adapter?

To do this, just use elementRef.nativeElement.textContent = ... directly

universal?

@IgorMinar
Copy link
Contributor

IgorMinar commented Nov 23, 2016

BrowserAdapter is not a public API, universal has been reaching into private API space. This is a known issue and we are working on fixing this in Universal.

// @vikerman @gdi2290 @jeffbcross

@tbosch
Copy link
Contributor

tbosch commented Nov 23, 2016

The change was introduced in d708a88. However, this was already in 2.2.0, but somehow we didn't update our bundles correctly...

DzmitryShylovich referenced this issue Dec 16, 2016
But use the DOM apis directly.
This also creates a separate `ServerRenderer` implementation
for `platform-server` as it previously reused the `BrowserRenderer`.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime regression Indicates than the issue relates to something that worked in a previous version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants