Skip to content

SPFx webpart breaks javascript frameworks (jQuery and Bootstrap) #5840

@Brank

Description

@Brank

Category

  • Bug

Describe the bug

We have a publishing site using a custom master page to load some Javascripts and frameworks such as JQuery and Bootstrap, we have some custom webparts using SPFx that render HTML for bootstrap components such as a carousel. One day bootstrap components just stop working as expected. We have seen that the bootstrap component just stop working even if it is in a content editor webpart when a SPFx webpart is added to the page.

In the console we have the following errors:
2020-06-05

Steps to reproduce

  1. Create a site publishing site
  2. Add a script editor with the following code (This is just for load the javascript and css for get bootstrap working, just in case you don't want to do it in your custom master page)
<script type="text/javascript" charset="utf-8">
var script = document.createElement('link');
script.onload = function() {
    var script2 = document.createElement('script');
    script2.onload = function() {
		var script2 = document.createElement('script');
		script2.onload = function() {
			var script2 = document.createElement('script');
			script2.src = "https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js";
			script2.onload = function() {
							//He terminado de cargar scripts
			};
			document.head.appendChild(script2); //or something of the likes
		};
        script2.src = "https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js";

		document.head.appendChild(script2); //or something of the likes
    };
    script2.src = "https://code.jquery.com/jquery-3.5.1.slim.min.js";

    document.head.appendChild(script2); //or something of the likes
};


script.href= "https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css";
script.type="text/css"
script.rel="stylesheet"
document.head.appendChild(script); //or something of the likes

</script>
  1. Add a content webpart with the following code (this is the bootstrap carousel):
<div class="carousel slide" id="carouselExampleIndicators" data-ride="carousel">
   <ol class="carousel-indicators">
      <li data-slide-to="0" data-target="#carouselExampleIndicators">​<br/></li>
      <li class="active" data-slide-to="1" data-target="#carouselExampleIndicators">
      </li>
      <li data-slide-to="2" data-target="#carouselExampleIndicators">
      </li>
   </ol>
   <div class="carousel-inner">
      <div class="carousel-item"> 
         <img class="d-block w-100" alt="First slide" src="/sites/IntranetR4/test/Paginas/..."/> &#160;
      </div>
      <div class="carousel-item active"> 
         <img class="d-block w-100" alt="Second slide" src="/sites/IntranetR4/test/Paginas/..."/> &#160;
      </div>
      <div class="carousel-item"> 
         <img class="d-block w-100" alt="Third slide" src="/sites/IntranetR4/test/Paginas/..."/> &#160;
      </div>
      &#160;
   </div>
   <a class="carousel-control-prev" role="button" href="#carouselExampleIndicators" data-slide="prev"> 
   <span class="carousel-control-prev-icon" aria-hidden="true"></span> 
   <span class="sr-only">Previous</span> </a> 
   <a class="carousel-control-next" role="button" href="#carouselExampleIndicators" data-slide="next"> 
   <span class="carousel-control-next-icon" aria-hidden="true"></span> 
   <span class="sr-only">Next</span> </a> 
</div>
  1. Check if carousel is working (it should be expected to be working)
  2. Edit the page and add a SPFX webpart (it could be the one created by yeoman with ReactJS without doing any other modifications)
  3. See that carousel stop working.

Expected behavior

Carousel shouldn't stop working, the correct behavior was doing it some weeks ago.

Environment details (development & target environment)

Tooling: SPFx v1.10.0
Target Environment: SharePoint Online

Additional context

Few weeks ago we have an intranet made with SPFx webparts that renders HTML to get some bootstrap components, one day withtout doing any code modification or loading new javascript these components just stop working as expected.

Thanks in advance.

Best regards,

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:spfxCategory: SharePoint Framework (not extensions related)status:to-be-reviewedIssue needs to be reviewed by Microsoft for additional follow up / review.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions